Sunday, November 01, 2009

[Cpp-Programming] Re: Looping to get user input causes infinite loop

scanf("%[^\n]", expr);

Not familiar with using regex in scanf.  Perhaps it isn't clearing (flushing) the input buffer when you read a string in that way?  Try adding
fflush(stdin);
just before that line.

However, note that, apparently, this is technically not the correct way of doing it...

Welcome to the world of C++, where there's a 'gotcha' for everything you could ever want to do, and a solution that "usually works, unless you did this, except in the case where that happens, unless..."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

<< Home