#include<stdio.h>
int main(void) {
FILE *fp;
int ch;
fp = fopen("input.txt", "w");
printf("Enter data");
while ((ch = getchar()) != EOF) {
putc(ch, fp);
}
fclose(fp);
fp = fopen("input.txt", "w");
while ((ch = getc(fp)) != EOF) {
printf("%c", ch);
}
fclose(fp);
}
How does the first while
loop stop inputting from user?
Since there is EOF
present as a condition.
Or else do I need to use
for loop?