I
interec
I have a simple program in which I want to read a wstring using wcin
and then output the same string using wcout. The program takes a few
words separated by spaces as input. The problem is that only the first
word is outputted. Everything after the first space seems to be lost
in the output. My OS is redhat hat linux 4 ES. gcc 3.4.6.
How do I fix this and why its not working? Thanks
Code
====
#include <iostream>
#include <iomanip>
#include <locale>
#include <string>
using namespace std;
int main()
{
locale l("en_US.UTF-8");
wcin.imbue(l);
wcout.imbue(l);
wstring sSql;
wcout << L"Enter Sql Statement: "; // input
wcin >> sSql;
wcout << endl << endl;
wcout << L"You entered: " << sSql << endl; // output
return 0;
}
Sample Run
=========
$ g++ two.cpp
$ ./a.out
Enter Sql Statement: select a from b
You entered: select <-- what happened to everything after first
space ????$*#@X
$
and then output the same string using wcout. The program takes a few
words separated by spaces as input. The problem is that only the first
word is outputted. Everything after the first space seems to be lost
in the output. My OS is redhat hat linux 4 ES. gcc 3.4.6.
How do I fix this and why its not working? Thanks
Code
====
#include <iostream>
#include <iomanip>
#include <locale>
#include <string>
using namespace std;
int main()
{
locale l("en_US.UTF-8");
wcin.imbue(l);
wcout.imbue(l);
wstring sSql;
wcout << L"Enter Sql Statement: "; // input
wcin >> sSql;
wcout << endl << endl;
wcout << L"You entered: " << sSql << endl; // output
return 0;
}
Sample Run
=========
$ g++ two.cpp
$ ./a.out
Enter Sql Statement: select a from b
You entered: select <-- what happened to everything after first
space ????$*#@X
$