My question is how can I split argv into two parts and store the parts in two variables.
I want my program to get parameters then a delimiter and then again parameters like this:
./program parameter1 parameter2 \: parameter3 parameter4
As you can see, the escaped ':' will act like a delimiter, cutting the array in two parts.
Now I want to get a char *arr1[] which will hold parameter1 and parameter2 and another char *arr2[] which will hold parameter3 and parameter4. The parameters can be of different length.
How can I split argv and save the various parameters in two char *[]?
In the end I want to access (with my example in mind) arr1[0] and it should have the string parameter1 inside it, and arr1[1] should have the string parameter2 inside it.
Edit: The problem lies in saving the parameters into the two different char *arr[]. I don't know how to do that, because I only know how to initialize an array with a value.
char *arr1[]; !error
char *arr1[10]; works, but what if I have more than 10 parameters?
Thanks in advance!
arr1andarr2? Do you know how to iterate overargv? Do you know how to compare strings? etc. Please show as much of the code as you know how to do as a minimal reproducible example. Otherwise it is difficult to know exactly which parts you can do and which part you need help with.