C ++ getline方法用于不同的数组 [英] C++ getline method use for different arrays

查看:108
本文介绍了C ++ getline方法用于不同的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从文件中读取数据...并存储在单独的字符串数组中。我知道如何将整个文件读入一个数组。但我需要阅读10行并存储在一个数组和另外10行并存储在另一个数组中..同样8次。请帮助:)

i want to read data from a file... and store in separate string arrays. i know how to read the whole file into one array. but i need to read 10 lines and store in one array and another 10 lines and store in another array.. likewise 8 times.please help :)

推荐答案

好吧,如果新行是你的一行的指标,那么计算10个新行,当你到达第10个新行时,你将开始存储在你的下一个数组中。
well, if new line is the indicator of your one line, then count 10 new line, when you would reach the 10th new line you will start storing in your next array.


你好,



使用getline api并从文件中读取每一行并保持计数以从文件中读取行。

如果计数达到10则意味着停止添加到第一个CStringArray中。如果计数开始为11,那么开始添加到另一个CString数组。



就像明智一样你可以拆分。



问候

Ranjith
Hi there,

use getline api and read the each line from the file and maintain the count to read the lines from file.
if counts reach 10 means stop adding into first CStringArray. If the count starts 11, so start adding into another CString Array.

like wise you can split.

regards
Ranjith


这篇关于C ++ getline方法用于不同的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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