Im trying to write some code to use wide character functions under RedHat 9
with:
gcc & g++ version 3.2.2 20030222

glibc version 2.3.2-27.9.7

The following code doesnt work properly (i couldnt cut and paste from original code which is on another pc, i had to retype.. please excuse syntax errors if any).

Code:
#include <unistd.h>
#include <wctype.h>
#include <wchar.h>
#include <iostream>

int main&#40; int argc, char **argv &#41;
&#123;
    wchar_t lh&#91;2048&#93;;
    memset&#40; lh, 0, sizeof&#40; wchar_t &#41; * 2048 &#41;;
    wcscpy&#40; lh, L"This is a WIDE string" &#41;;

    wprintf&#40; L"&#91;WIDESTRING&#93;&#58; %ls", lh &#41;;
    std&#58;&#58;wcout << lh << std&#58;&#58;endl;
    printf&#40; "This is a non-wide printf\n" &#41;;
    std&#58;&#58;cout << "Non-Wide cout" << std&#58;&#58;endl;
    wprintf&#40; L"&#91;WIDESTRING&#93;&#58; %ls", lh &#41;;
    

    return 0;
&#125;
The output will be:

Code:
&#91;WIDESTRING&#93;&#58; This is a WIDE string
&#91;WIDESTRING&#93;&#58; This is a WIDE string
It will not do the wcout ??

Basically it seems whatever comes first gets printed be it wcout or wprintf, the second one wont print. Infact it seems to lock in the first type and prevent usage of other streams ?

The problem with this is it seems to also prevent other functions such as vswprintf() to work which is fairly annoying.

Can anyone enlighten me as to why this doesnt work or what i can do to fix it?


Many thanks.