When reading characters from standard input what does it mean when you are asked to sop on hitting EOF in the input?

End Of File.
It is operating system depended.
In Windows for example is iqual to the value -1.

Thanks,
Any idea what is the value of EOF in Linux

In Windows if you enter the keys Control + Z you get EOF, in Linux is Control + D I believe.
So, do a little code like

char ch = getchar();

and enter the EOF. Then

printf("%d", ch );

will display the value.

Thanks,
I just checked it out it is Control+d in Linux

> char ch = getchar();
It should be
int ch = getchar();

char holds all possible chars. To hold all possible chars and EOF, you need a bigger data type, thus int.

Nor is the returned value guaranteed to be -1, which is why there is a constant EOF declared for this purpose.

Eg.

int ch;
while ( (ch=getchar()) != EOF ) {
  /* do stuff */
}
commented: right! +2

> char ch = getchar();
It should be
int ch = getchar();

char holds all possible chars. To hold all possible chars and EOF, you need a bigger data type, thus int.

Nor is the returned value guaranteed to be -1, which is why there is a constant EOF declared for this purpose.

Eg.

int ch;
while ( (ch=getchar()) != EOF ) {
  /* do stuff */
}

good answer!! this is the solution

commented: I'm certainly glad we waited 5 years for you to give your approval to this ancient piece of information... -4
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.