hello,
si vous pouvez m'éclairer,
je ne comprend pas pourquoi mon code ne me retourne pas le contenu de mon tableau alimenté par getchar.
Merci à vous.
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 #include <stdio.h> #define TAILLE 20 void get_line (char * const line, int taille) { int c=0, i=0; while ((c = getchar() != '\n' && c != EOF && i < taille)) { line[i] = c; ++i; } line[i] = '\0'; } int main(int argc, const char * argv[]) { char line [TAILLE]; printf("\n"); get_line(line, TAILLE); printf("%s\n", line); return 0; }
Partager