Zeiger allgemein
By Matthias Fechner
Code
#include <stdio.h>
/* programm to see who a pointer works
Written by Matthias Fechner
*/
int main(void) {
int i,*ptr;
i=3;
ptr=&i;
printf("i=%d\n",i);
printf("ptr=0x%X\n",ptr);
printf("*ptr=%d\n",*ptr);
i=5;
printf("i=%d\n",i);
printf("ptr=0x%X\n",ptr);
printf("*ptr=%d\n",*ptr);
*ptr=8;
printf("i=%d\n",i);
return 1;
}
Result
~/c_tutor> gcc pointer.c idefix@idefix_mobil
~/c_tutor> ./a.out idefix@idefix_mobil
i=3
ptr=0xBFFFF8E4
*ptr=3
i=5
ptr=0xBFFFF8E4
*ptr=5
i=8