problem about wchar-t-Collection of common programming errors


  • Alcott
    c encoding wchar-t
    I’m trying to print out a wchar_t* string. Code goes below:#include <stdio.h> #include <string.h> #include <wchar.h>char *ascii_ = “????”; //line-1 wchar_t *wchar_ = L”????”; //line-2int main() {printf(“ascii_: %s\n”, ascii_); //line-3wprintf(L”wchar_: %s\n”, wchar_); //line-4return 0; }//Output ascii_: ????Question:Apparently I should not assign CJK characters to char* pointer in line-1, but I just did it, and the output of line-3 is correct, So why? How could printf() in

  • Zac
    c++ deprecated wchar-t
    Hello I have a pump class that requires using a member variable that is a pointer to a wchar_t array containing the port address ie: “com9”.The problem is that when I initialise this variable in the constructor my compiler flags up a depreciated conversion warning.pump::pump(){this->portNumber = L”com9″;}This works fine but the warning every time I compile is anoying and makes me feel like I’m doing something wrong.I tried creating an array and then setting the member variable like this:pump:

  • davy
    c linux console wchar-t wchar
    1 It’s really strange that wprintf show ‘?’ as 3A9 (UTF16), but wctomb convert wchar to CEA9 (UTF8), my locale is default en_US.utf8. As man-pages said, they should comform to my locale, but wpritnf use UTF16, why?excerpt from http://www.fileformat.info/info/unicode/char/3a9/index.htm? in UTFUTF-8 (hex) 0xCE 0xA9 (cea9)UTF-16 (hex) 0x03A9 (03a9)2 wprintf and printf just cannot be run in the same program, I have to choose to use either wprintf or printf, why?See my program:#include <stdio.h

  • Ajay
    c++ wchar-t
    I’m new to c++.I know wchar_t is wide character.What is wrong in the following code ?? Did i not include the appropriate library ??#include<iostream.h> #include<conio.h> void main() { wchar_t *s=L”Hello, World”; cout<<s; getch(); }

  • Nick Prowse
    visual-c++ visual-studio-2012 wchar-t c2664 lpcwstr
    I’m new to c++. Coding in VS Express 2012 with Update 1. OS is Win 7 Ultimate SP1 x86.For the code below, which is the contents of main.cpp (I’ve put under Source Files), I get the following errors:Error 2 error C2664: ‘RegSaveKeyW’ : cannot convert parameter 2 from ‘wchar_t’ to ‘LPCWSTR’ \registrybackup_test\registrybackup_test\main.cpp 17 1 RegistryBackup_testError 1 error C2440: ‘initializing’ : cannot convert from ‘const wchar_t [40]’ to ‘wchar_t’ \registrybackup_test\registrybac

Originally posted 2013-11-25 11:02:59.