Streams and commas

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hello,

Why does the following code print "fail" instead of "123"
in the vc 2005 beta?

Thanks

-John

#include "stdafx.h"

#include <sstream>

int _tmain(int argc, _TCHAR* argv[])
{
std::stringstream ss("123,456");

int x;

ss >> x;

if (ss.fail()) {
printf("fail");
} else {
printf("%d", x);
}

return 0;
}
 
Back
Top