我有一个字符数组,其中包含从 Web 检索到的文本文件。 逐行遍历此缓冲区并显示每个缓冲区的最佳方法是什么 行?
最佳答案
好吧,因为这是 C++,所以将您的 char 数组转换为字符串流,然后像处理任何其他流/文件一样处理它。 当然这样做会让你调用像 getline() 这样的函数。
string tmpstr(chararry,length); // length optional, but needed if there may be zero's in your data
istringstream is(tmpstr);
string line;
while (getline(is,line)) {
// process line
}
关于c++ - 逐行遍历char数组的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20158351/