如何返回字符串数组? [英] How to return array of strings?
本文介绍了如何返回字符串数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有功能:
int read_file() {
ifstream file("plik");
if(!file.is_open()) {
throw -1;
}
int i = 0;
string line[MAXSIZE];
while(getline(plik, line[i])) {
cout<<line[i]<<endl;
i++;
}
return i;
}
但我想返回字符串数组:
But i want to return array of strings:
行[]
我怎样才能做到这一点?
How can I do this?
推荐答案
不要。数组是不可拷贝。
Don't. Arrays are not copyable.
使用的std ::矢量&lt;标准::字符串方式&gt;
而不是
这篇关于如何返回字符串数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文