Generating Random Numbers, weird error code

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

//int dice[10] = {0};
int n,i;

int main()
{
//bool cont = true, gameover = false;
srand(unsigned(time(0)));
//unsigned userScore = 0, computerScore = 0;
cout << "Choose how many dice to roll: ";
cin << n;
for(i = 0; i < n; ++i)
i = rand()%6+1;
//dice[i] = rand()%6+1;
cout << i << endl;
return 0;
}

The Code is suppose to ask for a number of dice to roll and then generate that may random dice. This is just the intial stages of my program so I just want to start with having read in the number of dice and then spitting out however many were asked for. My problem is that I get back an error code which I don't understand.

error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std::operator <<

It does the c2784 40x and 1 error C2676 if that helps.

I believe that this results from a simple command that I am not placing in the code.
You have an outstream operator when you are using an instream.

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
#include <iostream> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio>
using namespace std;

//int dice[10] = {0};
int n,i;

int main() 
{ 
//bool cont = true, gameover = false;
srand(unsigned(time(0)));
//unsigned userScore = 0, computerScore = 0;
cout << "Choose how many dice to roll: ";

cin << n;
cin >> n;

for(i = 0; i < n; ++i)
i = rand()%6+1;
//dice[i] = rand()%6+1;
cout << i << endl;
return 0; 
}
Thank you! That fixed it.
Topic archived. No new replies allowed.