On Tue, Mar 16, 2010 at 5:03 AM, Ajay Mishra <[email protected]> wrote: > Guys > I am confused about the mechanism of EOF character.While I am typing > something like A,B,C it gives me values of 65,67,68 as mentioned in ASCII > code. > But when I press ctrl + Z on my command prompt(which means executing EOF > character) its value comes as -1.I know EOF is defined in header file of > stdio.h as :#define EOF (-1),thats why I get -1(I suppose). > My question is how ctrl+z relates EOF ?What is the mechanism here?
The OS sends its equivalent of EOF when you hit Ctrl-Z (or Ctrl-D in other OS implementations.) When the library receives that signal, it translates it into C's equivalent, which on your C implantation happens to be -1. -- PJH http://shabbleland.myminicity.com/tra http://www.chavgangs.com/register.php?referer=9375
