所以,我正在使用dev-C++。编译器工作正常,一个简单的hello世界程序与其他十几个简单的程序一起工作。这是我正在为班级工作的一项工作。该程序将编译但不能运行。其他程序运行
对我来说这个编译但它永远不会运行。它出什么问题了?
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
void getNames(vector<string> &vectorName, int &last, string temp);
int main() {
vector<string> names;
string tmp;
int last = 0;
getNames(names, last, tmp);
for(int j = 0; j < last; j++) {
cout << names.at(j) << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
void getNames(vector<string> vectorName, int &last, string temp) {
while (true) {
cout << "Enter a name (quit to stop): ";
cin >> temp;
if (temp == "quit") break;
vectorName.push_back(temp);
last = vectorName.size();
}
}
没有运行时错误? – 2014-10-27 21:13:40
定义“从不运行”。如果你手动运行它会怎么样?你有没有看到任何错误?如果是这样,他们是什么? – Adam 2014-10-27 21:14:00
我看到的第一件事是'getNames'定义的参数不同于你声明的(缺少一个'&') – Fezvez 2014-10-27 21:14:47