Specifying range for random number

code:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{

int r0 = 1 + rand() % ((7 + 1) – 1 );

cout << "r0 = " << r0 << endl;
}


i get these errors:

.cpp(9) : error C2146: syntax error : missing ')' before identifier '–'
.cpp(9) : error C2059: syntax error : ')'

ty in advance
That '–' is not the minus '-'

( If you want to get different random values each execution, you have to call srand() at the beginning of the program )
ty, my bad lol, this '–' was there because ive copy/pasted it :X

yea i know i have to use srand(), but it was no need to paste the whole code
ty anyway :)
Topic archived. No new replies allowed.