Hello kat9265,
In addition to what
Ganado has said here is something different.
I don't understand what I'm doing wrong
|
For a start: in the ".cpp" files for the C header files should be using the C++ version like "<ctime>" and "<cstdlib>".
using namespace std;
is not a good idea. It will eventually cause you problems in the future. Better to learn how and what to qualify with "std::" now while it is only just a few things.
Now is a good time to learn to give your variables a proper name. "m", "n" and "p" may mean something to you, but they could mean something different to some else. For "n" you could use "numOfInts" or "numsToGuess". For "p" maybe "ptrSomething" or somethingPtr". At least it is clear that it is a pointer to something. And "something" would be replaced with what the variable is pointing to.
In line 19 the space between "::" and the function may not be a problem, but it is not generally written that way.
in the for loop, line 26, you are setting
numbers[i] = (rand() % m) +1;
. That is understandable, but the next line
cin >> numbers[i];
will over wright the random number. That is if the user can figure out what they are waiting for. With out a prompt the "cin" does not do much except make the user wonder.
Line 50 calls the
generateNumbers
function, which returns a pointer, but line 50 never receives this pointer. But you did get it right on line 55.
Again on line 59 the user is wondering what to do.
Any time you have "cin" to get a value you need a prompt to let the user know what and maybe how to enter what is needed.
Lines 62 to 68 I do not understand what you are doing. Also adding to "sum" has me puzzled.
In line 93 "srand" change "NULL" to "nullptr" to be more up-to-date.
The error on line 108, as
Ganado has pointed out is an empty vector. It has no size. Your choices are either give the vector an initial size and use an index to the vector, like you would for an array, or use "push_back" to add to the vector. "push_back would be the better choice, so that you do not oversize the vector like you would an array. Done right that should not happen, but how easy is it to type "m" when you meant "n". As a single letter variable it would be hard to find.
That is what I see until I can load the program and compile and test it.
Andy