It is not returning two arrays. The function is supposed to return a pointer to int.
Then the return statement is returning slice_after which becomes a pointer to char.
The comma , in between slice_before and slice_after is the comma operator.
int * before_after_clauses(char *line){
int num = check_slash(line);
int start = 0;
char slice_before[num + 1];
char slice_after[num + 1];
memcpy(slice_before, line + start, (num -1)*sizeof(char)); //after before
memcpy(slice_after, line + num, (num)*sizeof(char)); //after slash
slice_before[num] = 0;
slice_after[num] = 0;
return slice_before, slice_after;
}
Err. I think either you misunderstand my question or I have no idea on what you are talking about.
That code will take *line and output two array.
for example.
line = '123\456789'
Check slash will check the position of '\' in the line and output two array.
slice_before as '123'
slice_after as '456789'
Oh I think I know what I should do but give me some pointers as well.
slice_before and slice_after's memory will be free once the function is done with. So I guess I should use malloc() to hold the memory of slice_before and slice_after. Then my function should return the 2 pointers pointing to those arrays??