You scan commas between your lines, and they are not in the text. Remove them from the template:
sscanf(test,"%[^'_']%[^'_']%[^'_']%[^'_']%s",tmp1,tmp2,tmp3,tmp4,tmp5);
, , . , :
sscanf(test,"%[^_]%[^_]%[^_]%[^_]%s",tmp1,tmp2,tmp3,tmp4,tmp5);
pmg, scanf, , :
sscanf(test,"%9[^_]%9[^_]%9[^_]%9[^_]%9s",tmp1,tmp2,tmp3,tmp4,tmp5);
:
int token_count = sscanf(test,"%9[^_]%9[^_]%9[^_]%9[^_]%9s",tmp1,tmp2,tmp3,tmp4,tmp5);
if ( token_count != 5 ) { fprintf(stderr, "Something went wrong\n"); exit(42); }