ambuli
asked on
function that reads a char array
Hi Experts,
I thought I knew this, but I am getting confused now. I need to return an array of strings to a caller.
How can I do it. The following code works, but the caller has to know the size. If I want the function to return any number of items, how can I do it. ( can you please provide example both using strings and char *)
Thanks.
I thought I knew this, but I am getting confused now. I need to return an array of strings to a caller.
How can I do it. The following code works, but the caller has to know the size. If I want the function to return any number of items, how can I do it. ( can you please provide example both using strings and char *)
Thanks.
void getArray(char* a[])
{
a[0] = "one";
a[1] = "two";
a[2] = "three";
a[3] = "four";
a[4] = "five";
}
int main()
{
char * arr[5];
getArray(arr);
for( int i = 0; i < 5; i++ )
{
cout << arr[i] << endl;
}
getchar();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER