C function calculates wrong with pointers : <p>so i've been on trying to coding my first commandline game. I've been coding in C now for about a few months and it's my first coding language. I had no real problems until i came to the point where i had to deal with this pointer conversion. </p>

<p>Here is my function: </p>

<pre><code>void attack(int * life, int * armor, char * name){

int difference;
const int damage = 15;

print_Name(name);
printf(" attacks!\n");                                                                       

if((*armor) &gt; damage){
    printf("The armor was able to defend the damage!\n\n\n");
    (*armor) = armor - damage;
}

if((*amor) &lt;= damage){
    printf("Your Armor broke!\n");
    difference = damage - (*armor);
    (*life) = (*life) - difference;
    (*armor) = 0;
    printf("The attack caused %i damage.\n\n\n", difference);
}

else if ((*armor) == 0){
printf("\nThe attack has caused %i damage.\n\n\n", damage);
(*life) = life - damage;
};
</code></pre>

<p>}</p>

<p>i translated my variables from german into english for a better understandment, but there might eventually be some typos. </p>

<p>the problem is, my game work fine for a few rounds. But after ~20-30 rounds i noticed that the damage output was wrong at some point and now i ran into this: </p>

<p><a href="https://i.stack.imgur.com/MPMYU.png" rel="nofollow noreferrer">enter image description here</a></p>

<p>i know there is something wrong with my if's and that there is a better way to work around with the pointer... Can you help me with my problem?</p>
