我在VC编译时出现 warning C4305: 'initializing' : truncation from 'const int' to 'char'这样的错误,很弱智,还请高手指点,怎么解决
我在VC编译时出现 warning C4305: 'initializing' : truncation from 'const int' to 'char'这样的错误,很弱智,还请高手指点,怎么解决,去掉这个警告?
解决方案 »
- HClient.exe 编译后怎么打不开?
- VC++很基础的问题(急用)
- 读文件!
- 关于插件制作各位高手有没有什么高见!在线等
- 关于CSOCKET的问题的请教
- 求一个CListCtrl类的原代码
- 关于存数到Xml文档中的问题(put_text中的数据)
- m_pwd = new CDialog,此时m_pwd都有值了,为什么m_pwd->m_hWnd为空???在线!
- windows API函数获取打印机状态,不管真实状态是什么,status一直显示0!!!!!!!!!~~~
- 组件调用 无法供应请求的类别
- 怎样让CTreeCtrl的每一个ITEM都能显示出一个文件夹图标来??就象WINDOWS资源管理器那样.
- 各位仁兄谁有 InstallShield 10.5教程
int ii;
ii = 10;
sprintf(ss, "%ld", ii);
char c;c = char(a);
void CLqd2View::OnYcH()
{
// TODO: Add your command handler code here
char chSend[7]={0xd7, 0x09, 0xb0, 0xff, 0x01, 0x11, 0x81};
m_SerialPort.WriteToPort(chSend);
}
在中间一行有报警
warning C4305: 'initializing' : truncation from 'const int' to 'char'
请大虾详细指点一下小弟,不胜感激
改成
unsigned char chSend[7]={0xd7, 0x09, 0xb0, 0xff, 0x01, 0x11, 0x81};
error C2664: 'void __thiscall CSerialPort::WriteToPort(char *)' : cannot convert parameter 1 from 'unsigned char [7]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast我犯糊涂了……,请指点一下
CSerialPort::WriteToPort(char *);
是char * 不是char,改一下吧:
void CLqd2View::OnYcH()
{
// TODO: Add your command handler code here
char chSend[7]={0xd7, 0x09, 0xb0, 0xff, 0x01, 0x11, 0x81};
m_SerialPort.WriteToPort(chSend);//(chSend)改为(&chSend)
}
warning C4305: 'initializing' : truncation from 'const int' to 'char'
你能确定不是 from 'const int' to 'char*'吗?