从编辑框中读取数据并保存
我想在编辑框中输入:
G00 x0 y0 z0
G01 x1 y1 z1
G02 x89 y78 z67
......
定义该字符串为str_Message,
我定义了一个类来存放数据
class CDot : public CObject
{
private:
double xx;
double yy;
double zz;
CString command;
public:
CDot(double x,double y,double z);
CDot();
virtual ~CDot();
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;}
};
我用 CDot dot;
double x,y,z;
char c1,c2,c3;
CString str;
sscanf(str_Message,"%s %c %lf %c %lf %c %lf",
str,&c1,&x,&c2,&y,&c3,&z);//获得x,y,z,str;
dot.SetX(x);
dot.SetY(y);
dot.SetZ(z);
dot.SetCommand(str);
来从编辑框中获得x y z 及str的值并存放到dot对象中
问题是我现在是多行字符串,我只能存取第一行G00 x0 y0 z0 到一个CDot对象dot 中,
但是第二行G01 x1 y1 z1怎么能放到另一个CDot对象中,
同理第三行,第四行,...而sscanf 好像只能读取一行,还有中间的换行符怎搞?
如果有不同的存放上述字符串到类中的思路,多指教.