Friday, July 31, 2009

How to flush input/output steams in c++?

i am using Microsoft Visual c++. If i enter a date as 09, it will not be taken. what is the reason???

How to flush input/output steams in c++?
using any numeric datatype for storing such numeric values will always supress 0, bcoz 0 has no significance in 09.


fflush() or flushing the buffer in this case would not be helpfull.


if u want the date to be shown like this u can store the final date using string (ie char* or char[ ]) or int [ ].





u can try itoa() for converting int to (ascii)string.


but then u have explicitly prefix a 0 in the string variable.
Reply:Don't really 100% know why because I can't see the code in question.


The 0 would just be ignored in most cases.
Reply:use fflush();


the sytax is


fflush(stdin);








wen u take input from the user it is stored in a buffer..n is not actually stored in variables...it is done wen buffer is full


No comments:

Post a Comment