Bonjour
Je m'entraîne avec les fonctions et ce que je veux faire, c'est écrire une fonction qui permet d'entrer 5 caractères au clavier et ensuite les afficher.
J'ai écrit ce code mais j'ai des erreurs :
C:\Backup\CCours\test2\main.c|9|warning: return type defaults to 'int'|
C:\Backup\CCours\test2\main.c||In function 'lecture':|
C:\Backup\CCours\test2\main.c|10|error: 'mots' redeclared as different kind of symbol|
C:\Backup\CCours\test2\main.c|8|note: previous definition of 'mots' was here|
C:\Backup\CCours\test2\main.c||In function 'main':|
C:\Backup\CCours\test2\main.c|22|error: 'mots' undeclared (first use in this function)|
C:\Backup\CCours\test2\main.c|22|error: (Each undeclared identifier is reported only once|
C:\Backup\CCours\test2\main.c|22|error: for each function it appears in.)|
C:\Backup\CCours\test2\main.c|24|error: 'i' undeclared (first use in this function)|
||=== Build finished: 5 errors, 1 warnings ===|
qui peux m'aider svp merci
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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
//------------------------
#define nbMots 5
#define lgMots 5
lecture(mots)
{
char mots[nbMots] [lgMots];
int i;
printf("Donnez %d mots\n",nbMots);
for (i=0; i <nbMots; i++)
scanf("%s",&mots[i] [0]);
}
int main()
{
lecture(mots);
printf("---------\n");
for (i=0; i<nbMots; i++)
puts(&mots[i] [0]);
return 0;
} |
Partager