Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (anonymous):

C++: How do you make getline() to stop reading when it encounters a # rather than a newline?

OpenStudy (anonymous):

If you mean reading up to but not including the first # that it encounters, you can write getline(cin, foo, '#'); i.e.: int main() { string foo; getline(cin, foo, '#'); cout << foo; } will, for instance, return "asdf" if you input "asdf#". Look up getline delimeter on the C++ tutorial page.

OpenStudy (anonymous):

haha thanks, i figured that out as I slaved through my introductory C++ project haha

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!