Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/articles/cpp-tutorials/)
-   -   Solve system of equation by Gaussian elimination (http://www.go4expert.com/articles/solve-equation-gaussian-elimination-t17552/)

SaswatPadhi 12Jun2009 23:38

Re: Solve system of equation by Gaussian elimination
 
Quote:

Originally Posted by kiddo (Post 48571)
What is the use of fflush(stdin)?
can you explain for me?
i don't really know about it,
but I often seen it after the end of a loop.....

nice....

Quote:

Originally Posted by shabbir (Post 48577)
Flushes the input buffer

It's a bad practice to use fflush(stdin) to flush the input stream.This method is UNPORTABLE, and hence should be avoided !
It will compile fine, but it's behavior is undefined on many C compilers.
But, it can be used safely with output stream.

To flush input stream, we can define something like :
Code: C

void my_fflush(FILE *pFile)
{
      char c;
      while( ((c = fgetc(pFile)) != EOF) && (c != '\n') );
}


and call it like :
Code: C

my_fflush(stdin);


:)


All times are GMT +5.5. The time now is 00:10.