confused using swprintf and wstring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is my little test program:

#include <iostream>
#include <wchar.h>
#include <string>

using std::wcout;
using std::wstring;
using std::endl;

int main(char** argv, int argc) {
	wstring s = L"blah";
	wchar_t o[50];
	swprintf(o, 50, L"%s", s.c_str());
	wcout << o << endl;
}

I would expect it to produce write "blah" on the standard output, but
instead it writes "b". Why is this?

Thanks,

James

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux