Bonjour à tous,
Pour l'instant en cours j'ai surtout vu les tableaux à 1 dimension, mais je voudrais un peu anticiper sur les choses basiques des tableaux à 2 dimensions.
J'ai ce programme :
Ma structure ne marche pas, il est écrit "Array has incomplete element type 'int []' ".
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 #include<stdlib.h> #include <stdio.h> #define DimLigne 2 #define DimColonne 2 void LigneEtoile() /* Ligne d'etoiles */ { int i; printf("\n"); for (i = 0; i < 15; i++) { printf("*"); } printf("\n"); printf("\n"); } void AfficheTableau2d(int *Tab[][]) /* Procédure d'affiche d'un tableau à 2 dimensions */ { int x, y; for(x = 0; x < DimLigne; x++) { for(y = 0; y < DimColonne; y++) { printf("Tab[%d][%d]=%d", x, y, Tab[x][y]); printf("\n"); } } } int main () { /* Remplissage du tableau à 2 dimensions */ int tab[DimLigne][DimColonne]; for(int x = 0; x < DimLigne; x++) { for(int y = 0; y < DimColonne; y++) { printf ("Saisir tab[%d][%d] : ", x, y); scanf("%d", &tab[x][y]); } } LigneEtoile(); /* Affichage du tableau à 2 dimensions saisi avant */ for(int y = 0; y < DimLigne; y++) { for(int x = 0; x < DimColonne; x++) { printf("tab[%d][%d]=%d", y, x, tab[y][x]); printf("\n"); } } LigneEtoile(); AfficheTableau2d(tab); return 0; }
Je voudrais juste que ma fonction m'affiche le tableau précédemment remplit, comme le fait la partie du programme déjà écrite.
Je précise que j'utilise Xcode.
Pourriez-vous m'aider sur cette structure ?
Merci d'avance !
Partager