By using an if statement how could i get a character to detect end-of-file.

i was thinking something like this:

char a = '\0';
int count = 0;

if(a == EOF)
{
    count++;
}//endif

but it doesn't seem to detect the end-of-file. Any idea would be appreciated.

Thanks

zingwing

A character doesn't detect EOF. Reading the file detects EOF.

Based on what little you posted, that's about all we can say.

Maybe you are confusing EOF with end-of-string NULL terminators? The last character of a standard C or C++ string is '\0', which is called a NULL terminator.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.