Skip to main content
gamedev.net
🔒 Locked

strings

Started by icecubeflower 0 replies 700+ views
Original Post
icecubeflower
icecubeflower
Hey if getline() works like this: istream& getline (char* s, streamsize n ); istream& getline (char* s, streamsize n, char delim ); is there anyway to send it strings? I used to use only character arrays but I've moved on to strings. But it looks like I need to send a character array to getline(). ...oh wait hold on. Oh wait there's a string one: istream& getline ( istream& is, string& str, char delim ); istream& getline ( istream& is, string& str ); Glad I could help everyone. Keep fighting strong!
Fruny
Fruny
You indeed need to use the free function version.

std::string str;std::getline(std::cin, str);
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.