This commit is contained in:
Geoffrey Frogeye 2016-03-23 08:35:27 +01:00
parent 75553a72a1
commit 72d2f70b99
2 changed files with 37 additions and 0 deletions

28
TP4/E1.c Normal file
View file

@ -0,0 +1,28 @@
/* Pointeurs sur tableau */
#include <stdlib.h>
#include <stdio.h>
#include <math.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;
}

9
TP4/Makefile Normal file
View file

@ -0,0 +1,9 @@
all: $(patsubst %.c,%.exe,$(shell ls *.c))
%.exe: %.c
gcc $< -o $@ -lm
.PHONY: all clean
clean:
rm *.exe