请教大家关于16进制转换的问题,麻烦大家看看错在哪里 vs2010mfcc++乱码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 函数上面还有一部分代码:void CFactionSet::EditSend(int row,CString str){ char temp[2]={0x0}; if (row==116||row==117) { char *str1=(char*)malloc(1); temp[1]=0x00; str1=(LPSTR)(LPCTSTR)str; temp[0]=*str1; } else { str.Replace("%",NULL); if (str.GetAt(0)=='-') { str.Replace("-",NULL); float num=atof(str.GetBuffer(0)); temp[0]=*MultUpling(row,num); temp[1]=*(MultUpling(row,num)+1); temp[0]=~temp[0]; temp[0]=temp[0]|0x80; temp[1]=~temp[1]; temp[1]=temp[1]+1; if (temp[1]==0x0) { temp[0]+=1; } } else { float num=atof(str.GetBuffer(0)); temp[0]=*MultUpling(row,num); temp[1]=*(MultUpling(row,num)+1); } } CMainFrame *m_MainFrame=new CMainFrame; unsigned char tempTo[6]={0x01,0x06}; tempTo[3]=(unsigned char)m_row; tempTo[4]=(unsigned char)temp[0]; tempTo[5]=(unsigned char)temp[1]; unsigned char b[sizeof(tempTo)*2]={0}; unsigned long outlen=sizeof(tempTo)*2; m_MainFrame->byte2hex(tempTo,sizeof(tempTo),b,&outlen); CString temp1=b; temp1=temp1.Left(temp1.GetLength()-2); CString temp2=m_MainFrame->crcString(tempTo,sizeof(tempTo)); temp2=temp2.Left(4); temp1+=temp2; temp1=m_MainFrame->ChangeCharstr2Hexstr(temp1); m_SerialPort.WriteToPort(temp1.GetBuffer(temp1.GetLength()),temp1.GetLength()); delete m_MainFrame;}LPSTR CFactionSet::MultUpling(int row,float num){ float num0=0.0; if (CompareEditMul1(row)!=65535) { num0=num; } else if (CompareEditMul10(row)!=65535) { num0=num*10; } else if (CompareEditMul100(row)!=65535) { num0=num*100; } else if (CompareEditMul1000(row)!=65535) { num0=num*1000; } int num1=(int)num0; return HexExchange(num1);} 搞这么复杂,给个我写的试验函数,10进制转N进制,其中 jz=进制,16进制时 jz=16// 十转N进制CString CNumChangeDlg::ChangNub(__int64 def,int jz){ int tn=0; // 未数 __int64 tz=0; CString str=_T(""); tn=def%jz; tz=def/jz; str=DotToStr(tn); for(int i=0;;i++) { tn=tz%jz; tz=tz/jz; str=DotToStr(tn)+str; if(tz<jz) break; } str=DotToStr(tz)+str; // 去掉前导0 CString h; for(;;) { h=str.Left(1); if(h==_T("0")) str=str.Right(str.GetLength()-1); else break; } return str;} 关于那些指代不明的错误该怎么修改 CreateProcess的疑问 关于使用EnterCriticalSection一些问题 哪位有Cximage库显示GIF图片的代码吗 关于读取其他程序中控件或者内容的问题 请教大虾 vc中variant_t怎样转换成字符串型的值? MFC用什么方法联接ORACLE数据库好???thanks! shfileOperation问题? 很COOL的代码可惜我看不懂,大家帮帮忙啊.来着有分.高手请进.有点汇编的成分. 请教opencv的SIFT,检测到的关键点很少的问题 新人求帮助,弱智问题大神勿喷,VC6发布问题 VS2010生成的setup无法安装
void CFactionSet::EditSend(int row,CString str)
{
char temp[2]={0x0}; if (row==116||row==117)
{
char *str1=(char*)malloc(1);
temp[1]=0x00;
str1=(LPSTR)(LPCTSTR)str;
temp[0]=*str1;
} else
{
str.Replace("%",NULL);
if (str.GetAt(0)=='-')
{
str.Replace("-",NULL);
float num=atof(str.GetBuffer(0));
temp[0]=*MultUpling(row,num);
temp[1]=*(MultUpling(row,num)+1);
temp[0]=~temp[0];
temp[0]=temp[0]|0x80;
temp[1]=~temp[1];
temp[1]=temp[1]+1;
if (temp[1]==0x0)
{
temp[0]+=1;
}
}
else
{
float num=atof(str.GetBuffer(0));
temp[0]=*MultUpling(row,num);
temp[1]=*(MultUpling(row,num)+1);
}
}
CMainFrame *m_MainFrame=new CMainFrame;
unsigned char tempTo[6]={0x01,0x06};
tempTo[3]=(unsigned char)m_row;
tempTo[4]=(unsigned char)temp[0];
tempTo[5]=(unsigned char)temp[1];
unsigned char b[sizeof(tempTo)*2]={0};
unsigned long outlen=sizeof(tempTo)*2;
m_MainFrame->byte2hex(tempTo,sizeof(tempTo),b,&outlen);
CString temp1=b;
temp1=temp1.Left(temp1.GetLength()-2);
CString temp2=m_MainFrame->crcString(tempTo,sizeof(tempTo));
temp2=temp2.Left(4);
temp1+=temp2;
temp1=m_MainFrame->ChangeCharstr2Hexstr(temp1);
m_SerialPort.WriteToPort(temp1.GetBuffer(temp1.GetLength()),temp1.GetLength());
delete m_MainFrame;}LPSTR CFactionSet::MultUpling(int row,float num)
{
float num0=0.0;
if (CompareEditMul1(row)!=65535)
{
num0=num;
}
else if (CompareEditMul10(row)!=65535)
{
num0=num*10;
}
else if (CompareEditMul100(row)!=65535)
{
num0=num*100;
}
else if (CompareEditMul1000(row)!=65535)
{
num0=num*1000;
}
int num1=(int)num0;
return HexExchange(num1);
}
CString CNumChangeDlg::ChangNub(__int64 def,int jz)
{
int tn=0; // 未数
__int64 tz=0;
CString str=_T(""); tn=def%jz;
tz=def/jz;
str=DotToStr(tn);
for(int i=0;;i++)
{
tn=tz%jz;
tz=tz/jz;
str=DotToStr(tn)+str;
if(tz<jz)
break;
}
str=DotToStr(tz)+str;
// 去掉前导0
CString h;
for(;;)
{
h=str.Left(1);
if(h==_T("0"))
str=str.Right(str.GetLength()-1);
else
break;
} return str;
}