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;
}
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.