My function has this prototype:
char[][100] toArray(char document[]);
g++ on cygwin returns this error:
Unable to resolve identifier toArray
How do I return an array of C-Strings?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s impossible to return an array in C++. The closest you can do is return a pointer to a dynamically allocated block of strings.
This is legal code
The typedef makes it a little easier to understand. If you don’t believe me here’s the same code without the typedef
This is meant to scare you.
But although this code is legal it is also rubbish. You should be using
std::vector<std::string>. Dynamically allocating memory is hard, much harder than using classes that do the work for you.