I am trying to extract a string within paranthesis {abcdefg}
sscanf(line,"{%s}", value);
Example: {abcdefg}
after sscanf I get abcdefg}
How can I remove the right bracket? I need to get abcdefg
答案 0 :(得分:0)
With POSIX (s)scanf, you can use %[^}]
to extract everything up to a }
:
#include <stdio.h>
int main(){
const char* line = "{abcdefg}";
char extract[100];
sscanf(line, "{%[^}]", extract);
puts(extract); //prints abcdefg
return 0;
}