一个很奇怪的问题,请教高手
编写一个程序对一个文件文件进行读写,文本文件内容如下;
BSC-identification:JABSC05
comment:
network-element:SECTOR
BTS-type:METROBTS
non-key key non-key non-key key non-key
AZIMUTH BAND BLAT BLONG CELL CELLTYPE
30 800 390340 1656172 101 standard
………………………………………………………………………………
30 800 390340 1656172 101 standard是需要提取的数据。,后面省略的都是跟这一行格式一样。
我编写一段代码,用以读取文件文件的行数。
成员变量:
int NumOfLines;
DWORD endPosition;
CStdioFile LogFile;
先读取6行数据,当前文件指针应该是指向30 800 390340 1656172 101 standard这一行。再运行下面读取后面还有多少行数据。
void CProcessFile::ReadSubsetNumber()
{
CString strTemp;
DWORD PosCur;
this->NumOfLines=0;
PosCur=LogFile.GetPosition();//读取当前文件指针位置 ,跟踪结果显示为279
LogFile.ReadString(strTemp);
while(strTemp != "")
{
LogFile.ReadString(strTemp);
this->NumOfLines=this->NumOfLines+1;
}
LogFile.Seek(PosCur,CFile::begin);//希望能返回30 800 39034这一行
PosCur=LogFile.GetPosition(); //也是279
}
问题在于我再用LogFile.ReadString(strTemp);意图读取30 800 390340 1656172 101 standard这一行数据,结果strTemp读取出来的是390340 1656172 101 standard,少了前面30 800 两个数据,好像是文件指针发生了变化,当时我跟踪了前后的Pos文件指针位置,都是279。就不是很明白了,希望高手那个解释一下。