EOF означает конец файла, но вы не открыли какой-либо файл, поэтому как вы ожидаете, что он будет работать?
int main (void) \\ no problem using these . it just says no arguments to main
пример
int main( )
{
int a=40;
main(a); \\ you wont find any error with these
}
int main( void )
{
int a=40;
main(a); \\ you get error saying main function cant take arguments
}
main( ) it can take infinite arguments and whereas main(void) none arguments
Вот почему при использовании
getch(a) or clrscr(1) your passing arguments to these functions so you get error
because they are defined as clrscr( void ) getch (void )
strlen(char *) \\ can take only one argument
Вы можете проверить их в заголовочных файлах
Try these
c = 0; count = 0 ; initialize it so that you wont have any garbage value
while ((c=getchar)!='\n') or may be its AScll value
while ((c=getchar)!=13)
FILE *p;
p=fopen("hello.txt","r");
while ( c = getc(p) != EOF ) \ When it returns end of file while loop exits
Say You have these content in hello.txt
"hello world My name text file"
for every loop c has the character like h,e,l and when it returns to end it exits
Так что EOF в основном используется с файлами. Надеюсь, вы поняли