一行一行但是从eof读取。 [英] Read line after line but from the eof.

查看:78
本文介绍了一行一行但是从eof读取。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我怎么能从

文件末尾读取整个文本文件? (我想〜复制〜文件)


我想以这种方式复制文件:


文件1:
< br $>
a

b

c

file 2:


c

b

a

-

Ground21 ____________ \\

ground21 @ pocztaKROPKAfm

Hello.
How could I read the whole text file line after line from the end of
file? (I want to ~copy~ file)

I want to copy file in this way:

file 1:

a
b
c
file 2:

c
b
a
--
Ground21____________\\
ground21@pocztaKROPKAfm

推荐答案

Ground21写道:
Ground21 wrote:

你好。

我怎么读?整个文本文件从

文件结束后排成一行? (我想〜复制〜文件)


我想以这种方式复制文件:


文件1:


a

b

c


文件2:


c

b

a
Hello.
How could I read the whole text file line after line from the end of
file? (I want to ~copy~ file)

I want to copy file in this way:

file 1:

a
b
c
file 2:

c
b
a



最简单的方法是将所有行读成类似
的内容
std :: vector< std :: string,然后通过向量写入向后迭代的新文件

。只要你没有巨大的文件,这应该工作

ok。

The easiest way would be to read all the lines into something like an
std::vector<std::string, then write the new file iterating backwards
through the vector. As long as you don''t have huge files, this should work
ok.



最简单的方法是将所有行读成类似

std :: vector< std :: string,然后再向后编写新文件

通过向量。只要你没有巨大的文件,这应该工作

ok。
The easiest way would be to read all the lines into something like an
std::vector<std::string, then write the new file iterating backwards
through the vector. As long as you don''t have huge files, this should work
ok.



我想我写了一个不好的例子:


再一次:


file1:


text1

text2

text3

abctest


file2:


abctest

text3

text2

text1

-

Ground21 ____________ \\

ground21 @ pocztaKROPKAfm

I think I wrote bad example:

Once more:

file1:

text1
text2
text3
abctest

file2:

abctest
text3
text2
text1
--
Ground21____________\\
ground21@pocztaKROPKAfm


Ground21写道:
Ground21 wrote:

>
>

>最简单的方法是将所有行读成
std :: vector< std :: string,然后编写新的文件向后迭代
通过向量。只要你没有大文件,这应该可以正常工作。
>The easiest way would be to read all the lines into something like an
std::vector<std::string, then write the new file iterating backwards
through the vector. As long as you don''t have huge files, this should
work ok.



我想我写了一个不好的例子:


I think I wrote bad example:



无论如何我确实理解你的帖子。

I did understand your posting anyway.


再次:


file1:


text1

text2

text3

abctest


file2:


abctest

text3

text2

text1
Once more:

file1:

text1
text2
text3
abctest

file2:

abctest
text3
text2
text1



是的。你应该做的是逐行读取文件并将每一行作为一个单独的字符串放入一个向量中。所以稍后你会有一个线条向量。然后

您可以向后迭代该向量并再次将字符串写出



Yup. What you should do is read the file line by line and put each line as a
separate string into a vector. So later you have a vector of lines. Then
you can iterate through that vector backwards and write the strings out
again.


这篇关于一行一行但是从eof读取。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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