i am try to create a program that prints the numerical value of EOF...
any ideas for the function get the value of EOF using the ASCII table????

EOF doesn't have an ASCII value, it's required to be negative:

#include <stdio.h>

int main()
  printf("%d\n", EOF);
  return 0;

Also pay attention: getchar(), getc(), fgetc() functions return int (not char) values.
In essence, char type in C (but not in C++) is a very short int, that's all.

In essence, char type in C (but not in C++) is a very short int, that's all.

I think you will find char data type is the same in both c and c++.

In certain cases when dealing with text files or reading data from a "character device", the Microsoft MS-DOS shell (COMMAND.COM) or operating-system utility programs would historically append an ASCII control-Z character (aka the "SUB" character, 0x1A) to the end of a disk file

--source: wikipedia

Oh I see now what you meant. I thought you meant sizeof(char) in c++ is different than in C.

Remember, EOF is macro which associated with termination of file........

Member Avatar

if you want to end the file, then CTRL + Z, but numerical value of EOF is generally -1 .
you can check it by printing it's value using simple printf statement.

What is the value of EOF in c...?

The value of the macro EOF is completely irrelevant because it's an internal standard library flag that has no meaning to either you or the outside world. Though nitin1 is correct that it's usually defined as something like -1.

Member Avatar

yups! you don't need to care about that value, you can use it using the macro only. thanks.