I wanna know how can I read a string from input which contains spaces and by string,I mean a string class object.
thanks

I wanna know how can I read a string from input which contains spaces and by string,I mean a string class object.
thanks

Use the getline() function. For instance, if you have

string str;

then use

getline(cin, str);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.