列表 - 字符串 - 文本文件
我有一些关于文本文件、列表和字符串的问题。
我想知道是否可以放入读取文本文件中文本的代码,然后使用“string line;”或其他东西来定义文本的每个新行并将它们全部变成一个列表。因此,我可以对行进行排序,删除一行或两行甚至全部行,或者在文本中搜索特定行。
I've got a few questions concerning text files,list and strings.
I wonder if it is possible to put in a code which reads the text in a textfile,and then using "string line;" or something else to define each new row of the text and turn all of them into one list. So I can sort the rows, remove a row or two or even all of them or search through the text for a specific row.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 C++ 中,您通常使用 std::vector 来执行此操作:
对它们进行排序将如下所示:
删除第 N 行将如下所示:
In C++, you'd typically do this with an std::vector:
Sorting them would then look like:
Deleting row N would look like:
未指定语言,但我想它背后的设计是相同的:
我想这只是哪种语言的问题。所以是的,这是可能的。
The language wasn't specified but I would imagine the design behind it would be the same:
I suppose then it will be just a matter of which language. So yes it is possible.