首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

编译遇到的有关问题

2012-04-21 
编译遇到的问题代码如下:char buf[100]DWORD dwReadif(ReadFile(hPipe,buf,100,&dwRead,NULL)){MessageB

编译遇到的问题
代码如下:char buf[100];
DWORD dwRead;
if(ReadFile(hPipe,buf,100,&dwRead,NULL))
{
MessageBox(buf[1]);
//MessageBox(buf);

}
else 
{
MessageBox("读取数据失败!");
return;

}
现在MessageBox(buf);是没问题的,可读到相应的值。可是当我用MessageBox(buf[1]),我想显示buf[1]的值时候编译器就会报这样的错误
error C2664: 'MessageBoxA' : cannot convert parameter 1 from 'char' to 'const char *'
  Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
请问大仙如果解决 非常感谢!!!

[解决办法]
CString strTmp;
strTmp.Format(_T("%c"),buf[1]);
MessageBox(strTmp);
[解决办法]

探讨
这些方法都不行
csdn没有高人了吗

热点排行