为什么我的下面的代码输出乱码:
length=sqrt(((*it).first .x-(*it).second .x)*((*it).first .x-(*it).second .x)+((*it).first .y - (*it).second .y )*((*it).first .y -(*it).second .y ));
lengths.push_back (length);
CString msg,msg1,msg2;
msg1.Format ("%d",length);
msg2.Format ("%d",count2);
msg="A"+msg2;
msg=msg+"=";
msg=msg+msg1;
++count2;
TextOut(dc,((*it).first .x +(*it).second .x)/2,((*it).first .y +(*it).second .y )/2,msg,sizeof(msg));
只能够输出A0= ,A1= ,等,后面的那个长度就没有了,所以我分两次输出,像下面的这样写:
length=sqrt(((*it).first .x-(*it).second .x)*((*it).first .x-(*it).second .x)+((*it).first .y -(*it).second .y )*((*it).first .y -(*it).second .y ));
lengths.push_back (length);
CString msg,msg1,msg2;
msg1.Format ("%d",length);
msg2.Format ("%d",count2);
msg="A"+msg2;
msg=msg+"=";
++count2;
TextOut(dc,((*it).first .x +(*it).second .x)/2,((*it).first .y +(*it).second .y )/2,msg,sizeof(msg));
TextOut(dc,((*it).first .x +(*it).second .x+50)/2,((*it).first .y +(*it).second .y )/2,msg1,sizeof(msg1));
就可以了,但是有时候数据好像会出现这样的情况:
本来应该显示的是A2=318,结果却是A2=318C,那个C上面还有一个斜线,这个字符我打不出来,截图出来也发现帖子上面贴不了,有时候还会带2个那样类C的字符。请问是什么原因???还有这段代码:
CClientDC dc(this);
int i=0;
for( ;i<Nodnum;++i)
{
CString str1,str2,str3,str4;
str1.Format ("%d",i);
str1="e("+str1; str2.Format ("%d",ve[i]);
str3.Format ("%d",vl[i]);
str2=")="+str2;
str3=","+str3;
TextOut(dc,10,i*20,str1,sizeof(str1));
TextOut(dc,10+sizeof(str1)+30,i*20,str2,sizeof(str2));
TextOut(dc,10+sizeof(str1)+sizeof(str2)+60,i*20,str3,sizeof(str3-1));
本来要输出的是类似这样的:e(1)=3,3的,那个后面的那个3却输出不来了,估计也是跟上面的代码一样的错误????
length=sqrt(((*it).first .x-(*it).second .x)*((*it).first .x-(*it).second .x)+((*it).first .y - (*it).second .y )*((*it).first .y -(*it).second .y ));
lengths.push_back (length);
CString msg,msg1,msg2;
msg1.Format ("%d",length);
msg2.Format ("%d",count2);
msg="A"+msg2;
msg=msg+"=";
msg=msg+msg1;
++count2;
TextOut(dc,((*it).first .x +(*it).second .x)/2,((*it).first .y +(*it).second .y )/2,msg,sizeof(msg));
只能够输出A0= ,A1= ,等,后面的那个长度就没有了,所以我分两次输出,像下面的这样写:
length=sqrt(((*it).first .x-(*it).second .x)*((*it).first .x-(*it).second .x)+((*it).first .y -(*it).second .y )*((*it).first .y -(*it).second .y ));
lengths.push_back (length);
CString msg,msg1,msg2;
msg1.Format ("%d",length);
msg2.Format ("%d",count2);
msg="A"+msg2;
msg=msg+"=";
++count2;
TextOut(dc,((*it).first .x +(*it).second .x)/2,((*it).first .y +(*it).second .y )/2,msg,sizeof(msg));
TextOut(dc,((*it).first .x +(*it).second .x+50)/2,((*it).first .y +(*it).second .y )/2,msg1,sizeof(msg1));
就可以了,但是有时候数据好像会出现这样的情况:
本来应该显示的是A2=318,结果却是A2=318C,那个C上面还有一个斜线,这个字符我打不出来,截图出来也发现帖子上面贴不了,有时候还会带2个那样类C的字符。请问是什么原因???还有这段代码:
CClientDC dc(this);
int i=0;
for( ;i<Nodnum;++i)
{
CString str1,str2,str3,str4;
str1.Format ("%d",i);
str1="e("+str1; str2.Format ("%d",ve[i]);
str3.Format ("%d",vl[i]);
str2=")="+str2;
str3=","+str3;
TextOut(dc,10,i*20,str1,sizeof(str1));
TextOut(dc,10+sizeof(str1)+30,i*20,str2,sizeof(str2));
TextOut(dc,10+sizeof(str1)+sizeof(str2)+60,i*20,str3,sizeof(str3-1));
本来要输出的是类似这样的:e(1)=3,3的,那个后面的那个3却输出不来了,估计也是跟上面的代码一样的错误????
解决方案 »
- DebugProc中DEBUGHOOKINFO的成员idThread值总是为当前线程ID
- 图像偏色检测
- gb2312转码问题
- 调试时的错误
- ListCtrl只显示了标题,下面的内容怎么也显示不出来,已经摸索了三天了,请指教!还有...
- 紧急求助
- 我想用PostMessage进行进程间通讯,我怎么样得到目标进程的hWnd???
- OCX 中调用 OCX 中的方法和事件 如何能成功 再追加100分 在线等
- 【100分】我学什么语言才能学出这种脚本?
- 关于CDocument的OnCloseDocument()函数
- 请问如何在MSDN网站中找到一个win32 api 的详细说明,比如PeekMessage?
- 怎样在WebBrowser实现鼠标单击一个链接?
与问题无关的 建议:
CString msg,msg1,msg2;
msg1.Format ("%d",length);
msg2.Format ("%d",count2);
msg="A"+msg2;
msg=msg+"=";
msg=msg+msg1;
改成
CString msg;
msg.Format("A%d=%d",count2,length);
sizeof(str)的值是4
用str.GetLength()得到它长度