example-2.2.c
example-2.2.c · 905 B
From the archive c_pointers_examples.tar.gz
Download the archive « Back to the archive contents
#include <stdio.h> //| #include <stdio.h>
//|
void lower_hp( int *player_hp ) //| int lower_hp( int player_hp )
{ //| {
*player_hp = *player_hp - 10; //| return (player_hp - 10);
return; //| }
} //|
//| int main()
int main() //| {
{ //| int hp = 100;
int hp = 100; //|
int *pointer_to_hp; //| hp = lower_hp( hp );
//| printf( %d\n", hp );
pointer_to_hp = &hp; //| return 0;
lower_hp( pointer_to_hp ); //| }
printf( "%d\n\r", hp ); //|
//|
return 0; //|
} //|