(sorry for my bad english) :)
I made a simple program that allows the user to add something in the array, or close the program.
#include <stdio.h>
#define MAXSIZE 100
enum boolean{FALSE, TRUE};
int main()
{
char line[MAXSIZE], c, ch;
int i;
int state;
int state = TRUE;
while(state != FALSE){
printf("1.Add something in the array\n2.Print out the contenent of the array\n3.Exit\n");
ch = getchar();
if(ch == '1'){
system("cls");
printf("Type\n");
for(i = 0; i < MAXSIZE && (c = getchar()) != '\n'; i++){
line[i] = c;
}
line[i] = '\0';
}
else if(c == '2'){
system("cls");
printf("Contenent of the array\n");
for(i = 0; line[i] != '\0'; i++){
printf("%c", line[i]);
}
}
else if(c == '3'){
system("cls");
printf("End.");
state = FALSE;
}
}
return 0;
}
Well, nothing works ! But if I use EOF instead of '\n', the program at least lets me add chars in the array. The program doesn't work even if i use the switch statement instead of the if.
I don't know what to do, please help Thank you. :)
Aucun commentaire:
Enregistrer un commentaire