我想在编辑框中输入:
G00 x0 y0 z0
G01 x1 y1 z1
然后以一个类存放
class CDot
{
Private:
double xx;//保存x值
double yy;//保存y值
double zz;//保存z 值
CString Command//保存G
public:
CDot(double x,double y,double z);
double GetX(double xx);
double GetY(double yy);
double GetZ(double zz);
CString GetCommand(); 
}
该怎么做?
高手指教

解决方案 »

  1.   

    sscanf(buffer, "%s %lf %lf %lf",&g,&x,&y,&z)
    buffer为一行数据
      

  2.   

    同意楼上的!
    ////////////
    类定义:
    class CDot
    {
    Private:
    double xx;//保存x值
    double yy;//保存y值
    double zz;//保存z 值
    CString Command//保存G
    public:
    CDot(double x,double y,double z);
    double GetX(){return xx};
    double GetY(){return yy};
    double GetZ(){return zz};
    CString GetCommand(){return Command}; void SetX(double x){xx=x};
    void SetY(double y){yy=y};
    void SetZ(double z){zz=z};
    void SetCommand(CString str){Command = str}; 
    }假设控件的值是CString strText;
    方法如下:
    CDoc doc;
    int x,y,z;
    CString str;
    sscanf(strText,"%s %lf %lf %lf",str,&x,&y,&z);
    doc.SetX(x);
    doc.SetY(y);
    doc.SetZ(z);
    doc.SetCommand(str);
      

  3.   

    CDoc doc;
    float x,y,z;
    CString str;
    sscanf(strText,"%s %lf %lf %lf",str,&x,&y,&z);
    doc.SetX(x);
    doc.SetY(y);
    doc.SetZ(z);
    doc.SetCommand(str);