hi guys
I'm challenged to write a code for the following:
write a text up to 1000 characters, and get it back. the end of the text is detected though EOF on a new line or reaching 1000 characters.(EOF=ctr-Z on a new line)
I mainly have problem how to bring the EOF work probably. it doesn't react when I press ctrl-z directly . could you see the problem in the code?
Code:
int i;
char Text[1000];
printf("write the text:\n");
gets(Text);
for(i=0;i<=1000;i++){
Text[i]=getchar(); //read every sign
if((Text[i]=getchar()== '26' || i==1000)){ //26 is the ASCII code for ctrl-z
puts(Text);
}
}
return EXIT_SUCCESS;
}