问简单的文件读取问题。
文件内容如下:
SD 1 1 178 123 1 195 106 1 0
DD 5 5 267 85 1 299 57 57 0
......
SD 9 7 287 89 2 304 105 57 0
DD 10 10 515 85 3 492 57 60 0
DX 1 D1 150 113 0
LX 11 S1 329 92 1
......
DX 22 D2 655 134 1
LX 81 SF 726 92 1
然后用下面的语句读取:
CString buf;
CString strtemp1, strtemp2, strtemp3;
int m = 0, n = 0;
int itemp1 = 0, itemp2 = 0, itemp3 = 0, itemp4 = 0, atrr = 0;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0;
BOOL engross = 0;
while (file.ReadString(buf)) {
strtemp1 = strtok(buf.GetBuffer(0), " ");
if (strtemp1 == "SD" || strtemp1 == "DD" ) {
buf.Format("%s %d %s %d %d %d %d %d %d %d",
strtemp1, itemp1, strtemp2, x1, y1, atrr,
x2, y2, itemp2, engross);
pDoc->branch[m].InitData(strtemp1, itemp1, strtemp2,
x1, y1, atrr, x2, y2, itemp2, engross);
}
if (strtemp1 == "DX" || strtemp1 == "LX") {
buf.Format("%S %d %s %d %d %d",
strtemp1, &itemp1, strtemp2, &x1, &y1, &atrr);
pDoc->signal[n++].InitData(strtemp1, itemp1, strtemp2,
x1, y1, atrr);
}
}
但实际上只能读取strtemp1,这是什么原因?
应该怎么改?
谢谢!!