There is no error for sscanf , and this means that some variables can remain uninitialized and subsequently be used, for example
std::string str = "invalid"; unsigned int dd,mm,yy; cout << dd << " " << mm << " " << yy << endl; cout << "Arguments read: " << sscanf(str.c_str(),"%2d %2d %4d",&mm,&dd,&yy) << endl; cout << dd << " " << mm << " " << yy;
the above code may be emitted as a result:
32550 3249645428 32550 Arguments read: 0 32550 3249645428 32550
where all three arguments remain uninitialized.
source share