Streams and commas

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top