> I think you're going to have to use new[]/delete[].
That works, or if you don't want to mess with dynamic memory, I think using a static array might be a viable option here as well.
Code:
URL_Keyword_Mapping* read(std::ifstream& ifile, int& length) {
//Add the static identifier
static URL_Keyword_Mapping UKM_ARRAY[50];
//...
return UKM_ARRAY;
}
There are some complications with this method, though. Consider the following code:
Code:
URL_Keyword_Mapping* foo, *bar;
foo = read(blah, blah);
bar = read(blah, blah);
After this, foo and bar will point to the same array (the array that was written the second time read was called). If you want the original value of foo to be conserved, you'd have to declare it as an array and use memcpy.
The other alternative is to use a vector and to return the object itself, which, if efficiency isn't a concern, is probably the best option.