编译遇到的问题
代码如下: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);
[解决办法]