for a specific characters show me a number

in c++
How can i make a program that for a specific characters it will show me a number ?
e.x
for -*- must show me number 2
and when i cin --- program ends !!
Can anyone help me please?

1
2
3
4
5
  char a; 
cin >> a;
if ( a == '-*-' ) {
cout << 2;
} 
1
2
3
4
5
6
7
8
9
10
11
string x; // create a string
	
	do // do-while loop
	{
		cin >> x;

		if (x == "-*-") // if you enter -*-
		{
			cout << "2" << endl; // print out 2
		}
	} while (x != "--"); // loop runs as long as you don't enter -- 


If you're planning on actually learning c++, then you should look into learning how this works by yourself. The internet is your friend.
Last edited on
Thank you very much Tarik Neaj !! i will try it if i have any quest i will tell i am new in c++ and i am trying to learn it but thank you very much !!
Topic archived. No new replies allowed.