Bonjour,
Malgré mes recherches ("pointeur multi dimensionel") je ne parvient pas à résoudre mon probléme.
J'ai réduit mon code au strict, comment le faire marcher ?
Merci beaucoup de vos réponses.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 #include <stdlib.h> #include <stdio.h> int main(void) { int i; int j; const char liste[3][11] = { {"azertyuiop"}, {"qsdfghjklm"}, {"wxcvbn"} }; char **ptr_3; char *ptr_10; // Marche (acces en tableau) : /* * azertyuiop * qsdfghjklm * wxcvbn */ for (i = 0; i < 3; i++) { for (j = 0; j < 10; j++) { printf("%c", liste[i][j]); } printf("\n"); } // Ne marche pas (acces en pointeur) : ptr_3 = (char **)liste; for (i = 0; i < 3; i++) { ptr_10 = *ptr_3; // Plantage for (j = 0; j < 10; j++) { printf("%c", *ptr_10); // Plantage ptr_10++; } printf("\n"); ptr_3++; } return 0; }
Partager