Programmation Avancée en C


malloc2.c

00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 
00004 int main()
00005 {
00006     int *p;
00007     p = (int*) malloc(2 * sizeof(int)); // allocation de deux int
00008     if (p == NULL) return EXIT_FAILURE;
00009     *p = 14;
00010     *(p + 1) = 10;
00011     printf("p = %p \t *p = %d \t p+1 = %p \t *(p+1)=%d\n",
00012            p, *p, p+1, *(p+1));
00013     return 0;
00014 }