Hi guys,
I have been working from the book "C++ without fear" for a couple of weeks, and when i wrote this program from the book:
Code:
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int rand_0toN1(int n);
int main() {
int n, i;
int r;
srand(time(NULL));
cout << "Enter number of dice to roll: ";
cin >> n;
for (i = 1; i<=n; i++) {
r = rand_0toN1(6) + 1;
cout << r << " ";
}
return 0;
}
int rand_0toN1(int n) {
return rand() %n;
}
I was told by the compiler that there was a
"Parse error before '<' "
On the line saying:
Code:
cout << "Enter a number of dice to roll: ";
This seemed to be completely random as whatever I did to the code it still wouldn't work, but when I wrote another code that was EXACTLY the same it worked perfectly.
Please help, and I'm still a bit of a newbie, so please don't throw too much jargon at me!
Many thanks in advance
NWNN