iccaros Posted May 18, 2005 Report Share Posted May 18, 2005 ok I ran into a problem moving a program over to Vc++ to make sure it ran before sending in for home work.the linecout << s << flush;from my functionint promptUser (const string& s) { while (true) { int user_input; cout << s << flush; cin >> user_input; if (cin.fail()) { cerr << "invalid input \n"; cin.clear(); cin.ignore(); } else return user_input; }}throws an error. I had to change it to cout << s.cstr(); to make it work..any guesses on this one?thanks..I was banging my head aginst the wall as VC++ does not tell you where the error occured.. I think they want you to guess??at least with Dev-c++ ane Gcc it says array.cpp:34 where 34 is the line number Quote Link to post Share on other sites
jcl Posted May 18, 2005 Report Share Posted May 18, 2005 (edited) Huh. It builds and runs fine with both gcc -std=c++98 -pedantic and icc -strict_ansi. It should be fine unless both compilers are broken.I'll add this to the list of things to check in the standard.Edit: Does it work if you change that line tocout << s;cout.flush();? Edited May 18, 2005 by jcl Quote Link to post Share on other sites
iccaros Posted May 18, 2005 Author Report Share Posted May 18, 2005 Vc++ (visual C++)still throws an error..Gcc never had a problem wiht it.. or the Borland or Intel Compiler.. It's only Vc++ Quote Link to post Share on other sites
jcl Posted May 19, 2005 Report Share Posted May 19, 2005 (edited) Not sure what could be wrong. You might try to produce a minimal test case. Slice code out of the program until it starts working or you've reduced it to a single expression.Edit: Just to be clear, is it a compile-time or run-time error? Edited May 19, 2005 by jcl Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.