Help with pointers

#include <iostream>
#include <string>

using namespace std;

void getSize (int *numStrings);
void getSpace (int *numStrings, string newArray[]);
void inputData (int *numStrings, string newArray[]);

/* Calls the other functions; otherwise does almost nothing */

int main ()
{
int numStrings;

string* newArray;

getSize (&numStrings);

string*getSpace (int numStrings);
newArray = getSpace(numStrings);

inputData (&numStrings, newArray);

return 0;
}

/*getSize - which asks the user how many strings they want */
void getSize (int *numStrings)
{
cout << "How many strings would you like? " << endl;
cin >> *numStrings;
}

/*getSpace - which gets an array in the heap of the size requested by the user */
void getSpace (int numStrings, string newArray[] )
{
newArray = new string [numStrings];
}

/* inputData - which allows the user to input the strings and stores them */
void inputData (int *numStrings, string newArray[])
{
string data;
for (int i = 0; i < *numStrings; i++)
{
cout << "Please enter string #" << i << endl;
cin >> data;
newArray[i] = data;
cout << newArray[i] << endl;
}
}

I have a problem with my code and it says:
Undefined symbols for architecture x86_64:
"getSpace(int)", referenced from:
_main in main.o

so can someone help me debug this code. Thank you
First:
Please edit your post so that the code is within code tags. See http://www.cplusplus.com/articles/jEywvCM9/
Make the indentation systematic too.


The error message looks like it is from the linker (rather than compiler). If so, there are no syntax errors in the code.

The error message says that the main() calls a function that has name 'getSpace' and that takes one integer parameter.
The error message says that no object file included in linking contains implementation for such function.
The code, that you do show, does not contain implementation for such function. There is one 'getSpace', but that takes two parameters.

The compiler does not complain, because you do declare both versions of 'getSpace'.
Last edited on
Sorry for not putting the code within code tags but thank you so much for the help!
Topic archived. No new replies allowed.