Wednesday, October 10, 2007

How do i Flush!!

Most programs i write suffer from either stdout or stdin not getting empty when it is supposed to (when using Eclipse CDT, explicit flush id required for me to print anything).
while i can flush stdout using fflush(stdout);, i cant do the same thing with stdin, this was creating a major headache for me, and i came across a site which gave a code snippet to clear the buffer
   int ch;
  while( (ch = fgetc(fp)) != EOF && ch != '\n' )
   /* null body */;


Blogged with Flock

No comments: