Help with sscanf

sscanf does not stop at the first "&". How can I extract "doe" ?

char A[50] = "name=john&last=doe&job=vacant&";

char B[10] = "last";

char C[10] = "";

char *POINTER = strstr(A, B);

sscanf(POINTER + strlen(B), "=%s%*[^&]", C);

printf("%s\n", C); // doe&job=vacant&

That's because the %s in sscanf is creating problems so change it to...

sscanf(POINTER + strlen(B), "=%[^&]", C);

in this example, i would recommend strtok() instead of scanf.
Oh, and you don't need to allocate memory for a string already in memory.
The token gets set to 0.

#include <stdio.h>
#include <strings.h>

int main()
{
char A[50] = "name=john&last=doe&job=vacant&";

char *name, *last, *job;

name = strtok( A, "&" );
last = strtok( (char *)0, "&" );
job = strtok( (char *)0, "&" );

printf("name: %s\n", name );
printf("last: %s\n", last );
printf("job:  %s\n", job );

return 0;
}