|
From: Per W. <pw...@ia...> - 2003-04-11 10:58:42
|
But fflush() is not portable for input streams! It is only indended for flushing output streams. On a Linux, it would return EOF and set errno to EBADF if the stream isn't opened for output. /Per W On Fri, 11 Apr 2003, Ricardo L=F3pez Ruiz wrote: > scanf ( ) doesnot read the 'return' char, > then it stays in the input buffer until the next reading. > Two options for the next sentence: > (1) If you read in the next sentence with gets( ) > the 'return' char is transformed in the > empty char string: " " =3D '\0' . > (2) If you read a char in the next sentence with scanf( ) > the 'return' char it is transformed in the 'line jump'=3D'\n'. > > In consequence, if you dont want any strange/side effect in your input > the best option I know after an entry with scanf( ) it's to free the > input buffer: > > fflush(stdin). > > > Any other explanation is wellcome, > but I hope it can help you, > Ricardo. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugg= er > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNI= X > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |