Okay. Working on assignments here, trying to get them done...and I dunno if I am allocating this memory correctly. Note I am in a C++ class, so the programs we are given as homework require specific things...-but this particular thing is boggling me a bit, so I want to confirm whether or not I am doing this right:
The program already has the following inside of the main:
He tells me to allocate memory for the array with the new operator. So I do this.
names = new array[cellsUsed]
Note, cellsUsed is declared and set by the user before "string * names" is declared.
Is this correct or not?
Then I come to this...
We are using functions from an earlier exercise and one new function for this one. He says in a note on the function's prototype, in a comment. The functions name is inputArray.
"Note: On input, the space character ends a name."
This confuses me because I am going to use a for loop to do the input. Which is currently structured like this (I typed this myself)
1 2 3 4
|
for(int i = 0; i <= cellsUsed; i++)
{
in >> data[i]; //The function uses "istream & in" in the function parameters.
}
|
I think I'm missing something here, but I don't know what that is.
Any ideas what I may be missing?