Hello, so I am writing a code for an assignment that requires me to break an inputted string into an array of string arguments. Here is my code, which is within the main, to do so. It only puts the first token into my array, and the while loop never goes through a second time. I am wondering if anyone can help me figure out the error in this fragment of code.
Code:char** argsArray = malloc((sizeof(char*)*(numArgs+1))); int counter = 0; char* next; char *delimiters = " \t\n"; next = strtok(buffer, delimiters); while(next != NULL) { printf("Does this happen? \n"); argsArray[counter] = (char*)malloc((sizeof(char)*strlen(next))); strcpy(argsArray[counter], next); next = strtok(NULL, delimiters); printf("Element %d is: %s \n", counter, argsArray[counter]); counter++; }