EmbLogic's Blog

while( (c=getchar())!= EOF)

sir not able to get this….

2 Responses to while( (c=getchar())!= EOF)

  1. pushpa says:

    getchar function takes input from stdin character by character.its stored in a variable c.&that’s compared with EOF.EOF stands for END OF FILE.we use this while reading characters from a file.but here the character is read from stdin.so as per my understanding this loop has no use.

    • pushpa says:

      plz ignore my first comment.getchar returns the next character of keyboard input as an int. If there is an error then EOF (end of file) is returned instead.hence we need to compare it with EOF.variable c must be an int type.to come out of this loop we need to press cntrl-d from stdin.which internally generates a signal & getchar evaluates this error as EOF.

Leave a Reply to pushpa Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>