1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <stdlib.h>
#include <iostream>
#include <wchar.h>
int main(int argc, char** argv) {
//Set output to normal output, doesn't work properly without
FILE* openres=freopen(NULL,"w",stdout);
int res = fwide(stdout, -1);
printf("-------Char-------------\n");
//This should deprecated according to this doc http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1996/N0896.asc
char* deprecated = "This is deprecated";
printf("Using deprecated:\t%s\n", deprecated);
char testArray[] = "Standard char string/array.";
printf("Using char-array:\t%s\n", testArray);
char* test = &testArray[0];
printf("Using first element:\t%s\n", test);
test=testArray;
printf("Using array pointer:\t%s\n", test);
//Set stdout to wide-char mode
openres=freopen(NULL,"w",stdout);
res = fwide(stdout, 1);
if (res < 1) {
res=fwide(stdout,0);
printf("Couldn't switch to wide-char!");
return (EXIT_FAILURE);
}
wprintf(L"-------Wide-char--------\n");
wchar_t* wdeprecated = L"This is deprecated";
wprintf(L"WCHAR Using deprecated:\t%s\n", wdeprecated);
wchar_t wtestArray[] = L"Widestring string/array.";
wprintf(L"WCHAR Using char-array:\t%s\n",wtestArray);
wchar_t* wtest = &wtestArray[0];
wprintf(L"WCHAR first element:\t%s\n",wtest);
wtest=wtestArray;
wprintf(L"WCHAR array pointer:\t%s\n",wtest);
return (EXIT_SUCCESS);
}
|