On Sun, Jul 13, 2008 at 2:03 AM, Joel Dice <dicej@xxxxxxxxxxxxx> wrote: > On Sat, 12 Jul 2008, James Gregory wrote: > >> 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? > > I think you want "%ls". > Ah thanks, you are correct (well, actually it is L"%ls"). Annoyingly the first google hit for "swprintf" is an example from Microsoft which does what I was doing. James