我有个文本记录了一系列的数据,但中间有#注释,我该怎么读取?
比如有1000行有效数据,但中间插入了很多注释信息:
#点数
1000
123.45 2.545
25.45486 235.214
#说明-------------------注释没有规律
35.44 555.48该怎么识别#行呢,请大虾提示,谢谢!
比如有1000行有效数据,但中间插入了很多注释信息:
#点数
1000
123.45 2.545
25.45486 235.214
#说明-------------------注释没有规律
35.44 555.48该怎么识别#行呢,请大虾提示,谢谢!
解决方案 »
- CComboBox下拉框只能显示一点点?
- 请使用过BCGControlBar的朋友帮忙:outlookbar的自动隐藏功能为什么总出现ASSERT_VALID()错误,认真研究了两天,觉得BCGControlBar是不是有BUG
- HWND句柄如何转换成CString串?
- vc中tree控件文字和节点的背景颜色如何修改?
- 异常处理
- 求教!UDP网络传输buffer清空
- 请问如下错误是什么造成的
- SOS:请教如何在对话框中的picture控件中画图?
- 如何在一个应用程序中实现多个线程的并发?
- 怎样像金山毒霸那样在系统启动后最早运行?
- URL地址字符转换(Come On)!!!
- 如何画一个二维曲面?
while( buf=='#')
{
//移动到换行字符结束
if(buf=='\n')
{}
}
这是个字符处理的函数。。可以自己写一个的。
while( buf !='/0')
{
if (buf == '#')
{
//移动到换行字符结束
while(buf !='\n')
{ }
}
buf++;
}
CString fName;
DWORD dwCount;
DWORD dwLength;
CString fBuf;
char c;fName = "D:\\text.txt"; //change it according to your file
file.Open((LPCTSTR)fName,CFile::modeRead,NULL); //open file
if(!file)
{
TRACE("Open Error!\n");
exit(0);
}
dwLength = file.SeekToEnd(); //Get the file amount of byte
file.SeekToBegin();//set file pointer to the first byte
dwCount = 0;while(dwCount <= dwLength)
{
file.Read(&c,1);
dwCount++;
if('#' != c)
fBuf += c;
else
while(1)
{
file.Read(&c,1);
dwCount++;
if(0x0D == c) //seek to end of re
break;
else
{
file.Read(&c,1);
dwCount++
}
}
}This code is just simpleness,and I don't debug it.
If the re is chinese,I consider this code will be down.
So I just give you some ideas.
Best Regards
Thank you!