This is the task for which scanf
and company really shine.
char first_string[33], second_string[129]; sscanf(input_string, "%32s%*[^\"]%*c%128[^\"]%*c %d %d %d %d", first_string, second_string, &first_int, &second_int, &third_int, &fourth_int);
You probably want to do this in the if
so that you can check the return value to tell you how many of these converted fields (for example, you know how many integers you read at the end).
Edit: maybe some explanation would be helpful. Let it dissipate that:
% 32s reads the line in the first space (or 32 characters, whichever comes first).
% * [^ \ "] ignores input before the first "
.
% * c ignores another input byte (quote itself)
% 128 [^ \ "] reads the string in the quote (ie, until the next quote character).
% * c Ignores the final quote% d Reads int (which we did four times).
The space in front of every %d
really unnecessary - it skips spaces, but without a space, %d
skips leading spaces anyway. I have included them solely to make it more readable.
source share