fflush(stdin) isn't portable either, so that should probably be replaced
with cin.ignore(8) or something. (with the argument being greater if you
anticipate more than 8 chars of garbage in the stdin queue).
On Thu, 11 Aug 2005 08:35:45 -0700, Per Westermark <pw...@ia...>
wrote:
> Note that system("pause") isn't portable, and that Markella did post a
> solution similar in function to system("pause").
>
> /Per W
>
> On Thu, 11 Aug 2005, Lamana, Michael wrote:
>
>> Sounds more like a missing 'system("PAUSE");' statement. If the input
>> is the last thing in the program, it is probably just terminating
>> normally and closing the shell.
>>
>> -----Original Message-----
>> From: dev...@li...
>> [mailto:dev...@li...] On Behalf Of Markella
>> Krisztian
>> Sent: Thursday, August 11, 2005 6:14 AM
>> To: dev...@li...
>> Subject: Re: [Dev-C++] Execution Problem
>>
>> #include <iostream>
>> using namespace std;
>>
>> int main(int argc, char *argv[])
>> {
>> cout << "give me a number: "; int number; cin >> number;
>> cout << "you typed this number: " << number << endl;
>>
>> //maybe you need just this
>> //you wait for an Enter and keep the window open
>> fflush(stdin); cin.get();
>> return 0;
>> }
>> Krisztian
>>
>> >Hi,
>> >
>> >Whenever I enter the input data and hit enter, the output is not
>> >displayed and the run window closes immediately. i am using Dev C++
>> >4.9.9.2.
|