sscanf filtering the quotation mark ?

i normally use cin for having and input from the user but i found out that sscanf is alot more useful while parsing ,however now i dont seem to know why im having an additional " in the output


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;
int main () {
   int day, year;
   string a;
   char b[65];
   a= "This is \"junior\"";

   sscanf( a.c_str(), "This is \"%s\"", b);

   printf("%s", b );
}


output
junior"
sscanf will read until a white space character so the last " is read as well. If you don't want it to need to specify a terminator.
 
sscanf(a.c_str(), "This is \"%[^\"]s\"", b);

Output: junior
so the syntax of the terminator is [^ then the boundary \" then ] right ?
Topic archived. No new replies allowed.