This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP4/E1.c

28 lines
753 B
C
Raw Normal View History

2016-03-23 08:35:27 +01:00
/* Pointeurs sur tableau */
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int T[] = {12, 23, 34, 45, 56, 67, 78, 89, 90};
int *P;
P=T;
// Référence
printf("T = %d ; P = %d\n", T, P); // T = 557221504 ; P = 557221504
printf("&T = %d ; &P = %d\n", &T, &P); // &T = 557221504 ; &P = 557221496
printf("*T = %d ; *P = %d\n", *T, *P); // *T = 12 ; *P = 12
// Questions
printf("%d\n", *P+2); // 14
printf("%d\n", &T[4]-3); // 557221508
printf("%d\n", P+(*P-10)); // 557221512
printf("%d\n", *(P+2)); // 34
printf("%d\n", T+3); // 557221516
printf("%d\n", *(P+*(P+8)-T[7])); // 23
printf("%d\n", &P+1); // 557221504
printf("%d\n", &T[7]-P); // 7
return 0;
}