Yep, you're nearly there!
Code:
newargv[newargvSize] = (char*) malloc(strlen(word) + 1);
Originally Posted by
search
always get the error message -> array subscript is not an integer
Quite right, it is not an integer. It's a pointer, i.e. an address. You need to dereference the pointer. The dereferencing operator in C is *, and you need to use it whenever you want to access the value pointed to. So you should access the array like:
Code:
newargv[*newargvSize] = (char*) malloc(strlen(word) + 1);
Assign to newargvSize in parse like
The rest of it looks correct, if you can't return the size.
Code:
int parse(char *newargv[], int *newargvSize)
Code:
// main method
int newargvSize;
returnValue = parse(newargv, &newargvSize);
printf("newargvSize = %i", newargvSize); // no * needed here, newargvSize is not a pointer