将文本文件读入数组 [英] Read text file into array

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

问题描述

你好!我知道可以使用嵌套for循环或其他东西来读取数组并将其打印到文本文件中。是否也可以读入文本文件然后将值放在数组中?谢谢!

解决方案

绝对。你会阅读什么样的文本文件?你想要生成什么样的数组?



绝对。你会阅读什么样的文本文件?你想要生成什么样的数组?



很酷!我想读取一个名为file.txt的文件,该文件由N行和N列填充值。我需要一个数组[N] [N]然后我可以在代码中使用。


你知道提前有多少值吗?行数是否与列数不同?


Hi ! I know it''s possible to use a nested for loop or something to read an array and print it into a text file. Is it also possible to read in a text file and then put the values in an array ? Thanks !

解决方案

Definitely. What kind of text file will you be reading? What kind of array to you want to generate?


Definitely. What kind of text file will you be reading? What kind of array to you want to generate?

Cool ! I want to read in a file called file.txt which consists of N rows and N columns filled with values. I will need an array[N][N] that I can then use in code.


Do you know how many values there will be ahead of time? Is the number of rows different from the number of columns?


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

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