一段程序如下:
int n=0,p=0; 
int unDist[361],x[361],y[361];
unsigned short xd[361],yd[361],zd[361];
CString Dimcoordinate;
    UpdateData(TRUE);
    LPCSTR angle=m_strEditLaserAngle;
LPCSTR dis=m_strEditLaserHeight;
    if(m_bAngleHeightOK)    
{
for(int m=0;m<361;m++)
{
 x[p]=unDist[m]*cos(m*pi/360);
            y[p]=unDist[m]*sin(m*pi/360); xd[n]=(dis/sin(angle*pi/180)-x[p])*cos(angle*pi/180);// 722行
yd[n]=y[p];
zd[n]=(dis/sin(angle*pi/180)-x[p])*sin(angle*pi/180);// 724行
            CString Trans;
            Trans.Format(" %d , %d , %d ",xd[n],yd[n],zd[n]);
            Dimcoordinate+=Trans;
            n++;
p++;
}
       m_strEdit3DCoordinate=Dimcoordinate;
       UpdateData(FALSE);
}一编译就提示错误:C:\vcpp32\ex04a\For laser\For laserDlg.cpp(722) : error C2296: '*' : illegal, left operand has type 'const char *'
C:\vcpp32\ex04a\For laser\For laserDlg.cpp(722) : error C2296: '*' : illegal, left operand has type 'const char *'
C:\vcpp32\ex04a\For laser\For laserDlg.cpp(724) : error C2296: '*' : illegal, left operand has type 'const char *'
C:\vcpp32\ex04a\For laser\For laserDlg.cpp(724) : error C2296: '*' : illegal, left operand has type 'const char *'
请问怎莫解决  谢谢

解决方案 »

  1.   

    sin(angle*pi/180)你的angle 是字符串
    怎么能相乘呢?  先转换吧
    atoi, atof 试试
      

  2.   

    先将angle,dis转换为double类型的变量
      

  3.   

    你 angle  是 LPSTR类型的
    先把它转换成INT或者其他
      

  4.   

    LPCSTR angle是个CONST STRING 指针 *号只能用在数值型
      

  5.   

    貌似你的angle是从控件获取的?
    你控件 class wizard  Add Arraible时候,直接Value  ,int 吧,这样就不用转换了
      

  6.   

    void CStrDlg::OnButton1() 
        { 
        // TODO: Add your control notification handler code here 
        CString ss="1212.12"; 
        int temp=atoi(ss); 
        CString aa; 
        aa.Format("%d",temp); 
        AfxMessageBox("var is " + aa); 
        } 
    测试通过
      

  7.   

    强制转换成 int 和 double 都报错 C:\vcpp32\ex04a\For laser\For laserDlg.cpp(724) : error C2440: 'type cast' : cannot convert from 'const char *' to 'double'
            There is no context in which this conversion is possible   =.= 哪位能告诉我到底是哪种格式啊  谢谢
      

  8.   


    angle 替换为 strtod(angle,NULL)
    dis 替换为 strtod(dis,NULL)
      

  9.   

    非常感谢luohongming(lhm)  通过了    另外也感谢zzz3265(zzz)  xuayn312()  nkeverstar(月亮之星) 分别给分了  再次感谢