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:
I was told by the compiler that there was aCode:#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; }
"Parse error before '<' "
On the line saying:
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.Code:cout << "Enter a number of dice to roll: ";
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



LinkBack URL
About LinkBacks


