在vs2005以前版本的vs默认使用多字节字符集,而vs2005默认使用unicode字符集,这会使一些代码不能编译通过

其区别如下

unicode字符集

VS2005 宽字符 unicode字符集和多字节字符集void Point::output(int x, int y) { VS2005 宽字符 unicode字符集和多字节字符集    HWND hwnd=GetForegroundWindow(); VS2005 宽字符 unicode字符集和多字节字符集    HDC hdc=GetDC(hwnd); VS2005 宽字符 unicode字符集和多字节字符集    TCHAR buf[20]; VS2005 宽字符 unicode字符集和多字节字符集    memset(buf,0,20); VS2005 宽字符 unicode字符集和多字节字符集    int length; VS2005 宽字符 unicode字符集和多字节字符集    length=wsprintf(buf,TEXT("x=%d,y=%d"),x,y); VS2005 宽字符 unicode字符集和多字节字符集    TextOut(hdc,0,0,buf,length); VS2005 宽字符 unicode字符集和多字节字符集    ReleaseDC(hwnd,hdc); VS2005 宽字符 unicode字符集和多字节字符集}

 

多字节字符集

 

VS2005 宽字符 unicode字符集和多字节字符集void Point::output(int x, int y) { VS2005 宽字符 unicode字符集和多字节字符集    HWND hwnd=GetForegroundWindow(); VS2005 宽字符 unicode字符集和多字节字符集    HDC hdc=GetDC(hwnd); VS2005 宽字符 unicode字符集和多字节字符集    char buf[20]; VS2005 宽字符 unicode字符集和多字节字符集    memset(buf,0,20); VS2005 宽字符 unicode字符集和多字节字符集    wsprintf(buf,x=%d,y=%d",x,y); VS2005 宽字符 unicode字符集和多字节字符集    TextOut(hdc,0,0,buf,strlen(buf)); VS2005 宽字符 unicode字符集和多字节字符集    ReleaseDC(hwnd,hdc); VS2005 宽字符 unicode字符集和多字节字符集}

相关文章: