1> error C2664: 'sprintf' : cannot convert parameter 1 from 'const char [27]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: “sprintf”: 不能将参数 2 从“const char”转换为“LPCWSTR”与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
问题的原因是字符串ANSI和Unicode编码的区别: VC6与VS2003等默认使用ANSI编码,而VS2008默认采用Unicode。简单的说,ANSI用1个字节表示字符,Unicode用2个字节表示1个字符。
在VS2008中,设置如下:
1 进入project菜单进入最后一个***properties。
2、选择configuration properties --> General -->character set中设置 not set。
3、OK! 错误消失。