I'm a toal noob to programming. i just bought a C++ book and im trying to develop some very simple programs. I'm using dev C++. I'm stuck on this one, its having an issue linking. here is my code:
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int rand_1toN(int sides);
int main() {
int sides, times, x, r;
srand(time(NULL));
while(1){
cout<< endl << "Hello! This program will generate a random number between 1";
cout<< endl << "and any number you specify, however many times you want.";
cout<< endl << "Essentially rolling any sided dice you want as many times as you want.";
cout<< endl << "Enter 0 to exit.";
cout<< endl << "Enter the amount of sides the dice has:";
cin>> sides;
cout<< endl << "Enter the amount of dice want to roll:";
cin>> times;
if (sides == 0)
break;
else
for (x = 1; x <= times; x++) {
r = rand_1toN(sides);
cout << r << " ";
}
return 0;
}
}
here is the error message:
[Linker error] undefined reference to `rand_1toN(int)'
ld returned 1 exit status
I haventeven been able to test it so i dont even know if it will output what i want it to yet. a lot of what i have been doing is just trial and error on things that are probably obvious for a more experienced prgrammer. any help would be extremely appreciated!
thanks