multiple character if command

So I am trying to write a program for thread callouts where you enter the thread for example "1/4-20" and it displays the Diameters

and I currently have to run it with out any of the symbols, otherwise it thinks that it is an equation. I would like to turn this 1/4-20 into text so that it doesnt read it as an equation. Because I currently have to enter it in as "1420"


cout << "Please Specify Thread Callout : ";
cin >> x;

cout << endl << endl;

if(x==1420)
cout << "Major Dia / Minor Dia"

I currently have the variable x as an int I have tried using " char x;" but I can only use one character in the if command, anything more and it shows up as an error.

Is there anyway that I can use a line of text or a word, than if that word matches my if command it will display the desired text.

I apologize if the wording here is messy, I can't think of a good way to describe it other than I would like multiple characters to activate a certian action. So if I typed in a word and hit enter, and that word was correct, it would display something.
Last edited on
Use std::string
1
2
3
4
5
6
#include <string>
...
string str;
cin >> str;//or getline(cin, str); to accept spaces

if(str == "1/4-20") ...


By the way, you could do similar things with a char array, but it would be more of a pain.
Last edited on
Topic archived. No new replies allowed.