Getline和16h(26d)字符 [英] Getline and 16h (26d) character

查看:66
本文介绍了Getline和16h(26d)字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用(string)getline函数读取打开的文件中的单独行.问题是,getline将字符1Ah作为文件的结尾,如果该字符存在于行中,则整个读取将提前结束.有什么解决办法吗?

in VC++ environment Im using (string) getline function to read separate lines in opened file. Problem is that getline takes character 1Ah as end of file and if it is present on the line, whole reading ends prematurely. Is there any solution for this?

代码段:

fstream LogFile (Source,fstream::in);
string Line

while (getline(LogFile,Line))
{  ....  }

文件内容:

line1text1asdf
line2text2asd //EOF for getline here
line3asdas // this line will never be read by getline

感谢您提供任何信息.

Kra

推荐答案

用手动滚动功能替换getline,该函数逐个字符地读取字符,直到您定义的行或eof的结尾.

Replace getline with a hand-rolled function that reads in character by character until end of line or eof, as defined by you.

这篇关于Getline和16h(26d)字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆