I have a line that looks like this:
"HELLO 200 Now some random text\n now more text\t\t"
I am trying to get HELLO, 200 and the remaining line. Unfortunately, the string may contain \n and \t , so I cannot use %[^\n\t] .
I tried the following approach:
char message[MESSAGE_SIZE], response[RESPONSE_SIZE]; int status; sscanf (str, "%s %d %[^\0]", message, &status, response);
after that the variables are:
message = "HELLO", status = 200, response = "HELLO 200 Now some random text\n now more text\t\t"
Is there any way to do this without strtok?
source share