"error: no match for 'operator>>' in 'std::cout >> num'"?

This is the only error I've been getting for my program to generate random numbers between 1 and 9, display them and tell how many numbers it took to get a zero. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>			
#include <ctime>			
#include <cstdlib>			

using namespace std;			

int main() 						
{
	srand(time(0));
	int counter; char num;

	do
	{
		num == 	(1+rand()%9);
		switch(num)
		{
		case '0':
			cout >> num;  //Here is where the compiler says there's an issue
			break;
		default:
			counter++
			cout >> num;
			break;
		}
	}
	cout >> endl>> counter >> "numbers were generated before a zero came up";
	while(num != 0);
	return(0);


Any suggestions?
There is no overload operator >> with the left operand of type std::cout in C++. But there is overload operator << with the left operand of type std:;cout.

Maybe you should try this operator in statements

cout >> num;

and

cout >> endl>> counter >> "numbers were generated before a zero came up";

Or if you want to enter data in variable num then you should use

cin >> num;
Last edited on
Thanks. I'm just retarded sometimes, I forgot which one to use.
Topic archived. No new replies allowed.