how to save a specific variable

I would like to have a string but it will only accept input as one word i know this is a simple problem but can someone help?
i have so far in this section
#include <string>
string note="";
cin>> note;
cout << note << endl;
all of these are in seperate sections
Have two strings, your "note" and also one called "temp"

Save all input to temp and then check that with an if statement for the word you want

if(temp=="word_you_want")
{
note=temp;
}

else
//continue
i dont want to change what the program does based on their input i want it to be a note that they can see whenever they write 3 my menu choice to notes
but thanks i want my string to hold maybe a whole paragraph.
Last edited on
can you give me a specific example
not like you do all the work but maybe be more specific
Showing a note would be changing what it does wouldn't it?

I think the if statement still stands. If you have a whole paragraph of exact input, you can still get it the same way as above. The else was optional.
ok i see what your saying
uhm, having reread your question, I may have totally answered the wrong thing. Were you just worried about getting longer input? for that you could use cin.get

cin.ignore(80, '\n'); //clear buffer
cin.get(note, 800); //allows an 800 character input
cin.ignore(80, '\n'); //clear buffer
Try with:
getline(cin,note);
instead of
cin>>note;
Topic archived. No new replies allowed.