C中的Txt数据文件读取 [英] Txt Data File Reading In C

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

问题描述

我有一个包含以下数据的txt文件:


ABCDE ...

1 546 456 89 456

2 6546 654 5646 6546

3 444 565 789 789

例如


我希望能够读取文件,并能够在变量中存储一整行,然后与下一行的数字进行比较,然后将最大的一行写入文件(该部分很容易)......我真的需要一个程序可以逐行读取每一行直到文件结尾并将它们存储到一个变量中......

我知道这是可能的,但我一直讨厌使用文件......休息很简单,但我从来没有设法使用文件...


我真的很想帮忙请求e

I have a txt file with data like this:

A B C D E ...
1 546 456 89 456
2 6546 654 5646 6546
3 444 565 789 789

for example

I would like to be able to read the file and be able to store one whole line in variables and then compare with the next line''s numbers and then write the biggest line to a file (that part is easy)...I really need a procedure that can read each line one by one until end of file and store them into a variable...

I know that is possible but i''ve always hated working with files...The rest is pretty easy, but i''ve never manage to work with files...

I would really like some help please

推荐答案


我有一个txt文件,其数据如下:


ABCDE ...

1 546 456 89 456

2 6546 654 5646 6546

3 444 565 789 789
<例如,



我希望能够读取文件,并能够在变量中存储一整行,然后与下一行进行比较'' s号然后将最大的一行写入文件(该部分很容易)......我真的需要一个程序,可以逐个读取每一行直到文件结尾并将它们存储到变量中......


我知道这是可能的,但我一直讨厌使用文件...其余的很容易,但我我从来没有设法使用文件...


我真的很想帮助请
I have a txt file with data like this:

A B C D E ...
1 546 456 89 456
2 6546 654 5646 6546
3 444 565 789 789

for example

I would like to be able to read the file and be able to store one whole line in variables and then compare with the next line''s numbers and then write the biggest line to a file (that part is easy)...I really need a procedure that can read each line one by one until end of file and store them into a variable...

I know that is possible but i''ve always hated working with files...The rest is pretty easy, but i''ve never manage to work with files...

I would really like some help please



你好,

这里是alghorytham:


1)循环而指向文件的指针不能到达EOF(文件结尾);


2)使用getline,fgets或任何simmilar函数来提取单词行


3)循环后比较行


Savage

Hi,
here goes alghorytham:

1) Loop while pointer to file don''t reach EOF(end-of-file);

2) use getline,fgets or any simmilar function to extract sngle line

3) After loop compare lines

Savage





这里是alghorytham:


1)循环而指向文件的指针不能到达EOF(文件结尾);


2)使用getline,fgets或任何simmilar函数来提取单词行


3)循环比较后的行


Savage
Hi,
here goes alghorytham:

1) Loop while pointer to file don''t reach EOF(end-of-file);

2) use getline,fgets or any simmilar function to extract sngle line

3) After loop compare lines

Savage




ok ...我理解你写的是什么,但是使用getline如何将包含各种变量的行分成单个变量???



ok...i understand what you wrote, but using getline how can i seperate the line which contains various variables into the individual variables???


可能对于这部分它将是更好的,如果你在代码中写了几行评论,看看我是否能最终摆脱我有这个含水的鞋跟


谢谢你的帮助
probably for this part it would be better if you wrote a couple of lines in code with comments to see if i can finally get rid of this aquiles heel that i have

Thank you for your help


这篇关于C中的Txt数据文件读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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