M
mathieu
Hi,
I am having a hard time understanding how to use std::ws. I am
trying to parse a simple string (*). My goal would be that 'st'
contains 'Hello World'. I thought that using std::ws would indeed do
what I was looking for.
Thanks for suggestion,
-Mathieu
(*)
#include <iostream>
#include <sstream>
int main(int, char *[])
{
const char s[] = "1 2 3 Hello World";
std::istringstream is(s);
int a,b,c;
std::string st;
is >> a;
is >> b;
is >> c;
is >> std::ws;
is >> st;
std::cout << a << " " << b << " " << c << " " << st << std::endl;
return 0;
}
I am having a hard time understanding how to use std::ws. I am
trying to parse a simple string (*). My goal would be that 'st'
contains 'Hello World'. I thought that using std::ws would indeed do
what I was looking for.
Thanks for suggestion,
-Mathieu
(*)
#include <iostream>
#include <sstream>
int main(int, char *[])
{
const char s[] = "1 2 3 Hello World";
std::istringstream is(s);
int a,b,c;
std::string st;
is >> a;
is >> b;
is >> c;
is >> std::ws;
is >> st;
std::cout << a << " " << b << " " << c << " " << st << std::endl;
return 0;
}