Programmation Avancée en C


ptr_arith.c

00001 #include <stdio.h>
00002 
00003 int main() 
00004 {
00005     int i = 2;
00006     int *p1, *p2;
00007     p1 = &i;
00008     p2 = p1 + 1;
00009 
00010     printf("Adresse p1 = %p \t Adresse p2 = %p\n", p1, p2);
00011     printf("Différence des adresses: %lu \t sizeof(int)=%lu\n",
00012             (unsigned long)p2-(unsigned long)p1, sizeof(int));
00013     printf("MAIS p2-p1 = %d !\n",p2-p1);
00014     return 0;
00015 }
00016 
00017