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 :
void my_fflush(FILE *pFile)
while( ((c = fgetc(pFile)) != EOF) && (c != '\n') );
and call it like :