[Débutant] Initialiser un tableau de chaine de caractères
Bonjour,
je débute sur les chaines de caractères en C, j'ai suivi la doc du site en utilisant la fonction strcpy mais cela ne fonctionne pas.
Voici le code en question, j'essaie d'initialiser le tableau de chaines de 5 caractères nom[N][5] à 0 mais cela ne fonctionne pas
Code:
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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10
char nom[N][5];
int absi[N];
int ord[N];
void initTab() //initialise les tableaux à 0
{
int i;
for(i=0;i<N;++i)
strcpy(nom[i][5],"0");
for(i=0;i<N;++i)
{
absi[i]=0;
ord[i]=0;
}
}
void affiche() //affiche les tableaux
{
int i,j;
for(i=0;i<N;++i)
printf("%s",nom[i][5]);
printf("\n");
for(i=0;i<N;++i)
printf("%d",absi[i]);
printf("\n");
for(i=0;i<N;++i)
printf("%d",ord[i]);
printf("\n");
}
int main()
{
initTab();
affiche();
system("pause");
return EXIT_SUCCESS;
} |
merci pour votre aide