Cin problem.

Hi guys. I have a small problem that I can't solve. And I don't think the problem is that hard, except the professor puts a lot of restriction on what I can use. And I try a lot combo but none seem to work. No array..string..allowed..etc..only using cin/basic char. Normally I would just take in the string and goes through it without any problem. But I can't do any of that this time. The professor seem to hate the std for some reason. O_o

Here is my problem. I need the output to be able to do all three thing in the ex. But how do I check to see if the abc is already in, or not? So I can out put the phrase "Input card face value" depend on if the user have already inputed the abc follow the 3. Or have not?

ex:
Input number of card: 3abc

ex two:
Input number of card: 3
Input card face value: abc

ex three:
Input number of card: 5 a b c d e

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
	//userInput(); 
	char number1, number2, number3; 
	cout << "Please input number One: "; 
	cin >> number1; 

	if(number2 == NULL)
		cout << "Please input card face value: ";  
	cin >> number2 >> number3; 

	cout << "all three number is: " << number1 << number2 << number3; 
}



Last edited on
I'm not sure I fully understand you but an if should do the check e.g.
if number1 == something etc.
What I mean is that after the user input the first character. Which will indicate how many other characters they will input after that. They can automatically enter the rest of the character. Or wait till a promt asking them to enter the rest of the characters. How do I make it so that the promt will appear if the user have not already inputed the rest of character. And will not appear if the user have already inputted it.
Well the way forward is an if statement, just check the input after the user puts in the character and go with that.

E.g.
1
2
3
4
if (no1 == 'a') {
   // do whatever
}
// carry on with code 


Something like that would work.
lolz. Thx man, but that wasn't it. I just realized how the professor done it. He didn't do anything. No if statement or anything. It just the wording in his program.

He has a statement "Your cards face value is: ". Which is both a question, and a statement giving out the output. lolz. Cheap...

1
2
3
4
5
6
7
char number1, number2, number3;
cout << "Please input number of cards: "; 
cin >> number1; 

cout << "Your card face value is: "; 
cin >> number2 >> number3; 
Last edited on
LOL, thats entertaining at least, your prof. is a funny guy
Topic archived. No new replies allowed.