删除txt文件中的行 [英] delete line in txt file

查看:93
本文介绍了删除txt文件中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想要的东西应该真的很简单....但我不明白...

搜索google和stuf ,但没有发现任何有用的东西。


我;用fstream打开一个txt文件。现在我想创建一个函数,

看起来像Removeline(int Linenumber);但是我可以让它工作......任何人

有什么帮助吗?


如果有人可以帮助我那会很棒:D


thnkx !!

Hello all,

I want something that should be realy really simple.... but I dont get it..
searched google and stuf, but found nothing useful.

I;m opening a txt-file with a fstream. Now I want to make a function that
looks like Removeline(int Linenumber); But I can;t get it working.. anybody
has anything helpfull?

if anybody can help me that would be great :D

thnkx!!

推荐答案

10月9日晚上7:43,Joah Senegal < blo ... @ hva.nlwrote:
On Oct 9, 7:43 pm, "Joah Senegal" <blo...@hva.nlwrote:

大家好,


我想要的东西真的应该真的很棒很简单....但是我不明白..

搜索谷歌和stuf,但没有发现任何有用的东西。


我;打开一个txt文件与fstream。现在我想创建一个函数,

看起来像Removeline(int Linenumber);但是我可以让它工作......任何人

有什么帮助吗?


如果有人可以帮助我那会很棒:D


thnkx !!
Hello all,

I want something that should be realy really simple.... but I dont get it..
searched google and stuf, but found nothing useful.

I;m opening a txt-file with a fstream. Now I want to make a function that
looks like Removeline(int Linenumber); But I can;t get it working.. anybody
has anything helpfull?

if anybody can help me that would be great :D

thnkx!!



粘贴你正在努力工作的代码肯定会有所帮助

pasting the code you are trying to make work will surely help


10月10日,上午12:43,Joah Senegal < blo ... @ hva.nlwrote:
On Oct 10, 12:43 am, "Joah Senegal" <blo...@hva.nlwrote:

大家好,


我想要的东西真的应该真的很棒很简单....但是我不明白..

搜索谷歌和stuf,但没有发现任何有用的东西。


我;打开一个txt文件与fstream。现在我想创建一个函数,

看起来像Removeline(int Linenumber);但我可以;让它工作..任何人

有什么帮助吗?


如果有人可以帮助我那会很棒:D
Hello all,

I want something that should be realy really simple.... but I dont get it..
searched google and stuf, but found nothing useful.

I;m opening a txt-file with a fstream. Now I want to make a function that
looks like Removeline(int Linenumber); But I can;t get it working.. anybody
has anything helpfull?

if anybody can help me that would be great :D



单程:


将每一行读入std :: vector< std :: string然后

把那个向量写回来,减去你想要的行

删除。


-

Chris

One way:

Read each line into a std::vector<std::stringand then
write that vector back out, minus the line(s) you want
removeed.

--
Chris


嗨Joah,
Hi Joah,

I;用fstream打开一个txt文件。现在我想创建一个函数,

看起来像Removeline(int Linenumber);但是我可以;让它工作..任何人

有什么有用的吗?
I;m opening a txt-file with a fstream. Now I want to make a function that
looks like Removeline(int Linenumber); But I can;t get it working.. anybody
has anything helpfull?



我不是C ++ Guru,但这是我想要的概念。


打开两个文件指针p1和p2到你要删除的文件

行中.p2只读取而p1读取写入。


将p1放在linei,其中i表示i。是要删除的行,而

行i + 1上的p2。从p2读取行并将其写入p1。继续这样

直到你点击EOF。用空行或EOF填写最后一行。


我不知道这是否有用,但这是一个开始。


问候

Klaas

I''m not a C++ Guru, but this is the concept I would start from.

Open two file pointers p1 and p2 to the file where you want to delete
the line in. p2 is only reading while p1 is read write.

Place p1 on the line "i", where "i" is the line to delete, and p2 on the
line i+1. Read line from p2 and write it to p1. Continue like that
until you hit EOF. Fill the last line with an empty line or just EOF.

I don''t know if that would work, but it is a start.

Regards
Klaas


这篇关于删除txt文件中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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