For example, given input string "this is a test" I want to create an array of strings with 4 elements: "this", "is", "a", and "test". I also want to be able to change these strings later.
Below is the code I have tried. This seems to put all the characters into the first string in the array.
char string[] = "this is a test string"; //sample input string
size_t sizee = sizeof(string) - 1; //size of sample input string
char arrayOfStrings[sizee][sizee]; //the array of strings
int m = 0; //[m][n]
int n = 0; //[m][n]
for(int i = 0; i<sizee; i++){
if(string[i] != " "){
arrayOfStrings[m][n] = string[i];
n++; //
}
else{
m++; //if space char, move to next string in the array
n = 0;
}
}