Reputation: 113
If I want to get a substring between "/" "@", this one will work:
char buf[512] ="" ;
char src[512] = "iios/12DDWDFF@122";
sscanf( src, "%*[^/]/%[^@]", buf);
printf("%s\n", buf); //buf will be "12DDWDFF"
How can I get same result from "//^&#@iios////12DDWDFF@@@@122/&*@(@///";
char buf2[512] ="" ;
char src[512] = "//^&#@iios////12DDWDFF@@@@122/&*@(@///";
sscanf(src, "%*[4][^/]/%[4][^@]", buf2);
printf("%s\n", buf2); //buf2 gets nothing
or
sscanf(src, "%*[^////]/////%[^@@@@]", buf2);
printf("%s\n", buf2); //buf2 gets nothing
Upvotes: 1
Views: 379