【发布时间】:2015-02-03 20:48:46
【问题描述】:
类似
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
nr++; //how many lines in a text file
}
}
string y[nr] = {};
仅当我指定像 y[10] 这样的实际数字时才有效。
【问题讨论】:
-
std::vector<:string>> y;
-
用户不能“声明”数组。只有程序员可以。
-
相关:Does C++ support Variable Length Arrays? 和 Variable length arrays in C++? 后者可能使这个问题重复。