你能帮我解决我代码中的问题吗?
程序应该要求用户输入狗的名字,最后打印出第三只狗的名字。当我编译和执行该程序时,它说“它停止工作”并且 Windows 询问我是否要关闭该程序或做其他事情。
#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
string perros[10];
int i;
for(i=1; i<11; i++)
{
cout<<"Introduce el nombre del perro"<<endl<<i;
cin>>perros[i];
}
cout<<"El nombre del tercer perro es "<<perros[2];
system("pause");
}
最佳答案
你应该从 0 到 9 开始循环
for(i=0; i<10; i++)
希望这会消除错误...
关于c++ - 编译后可执行文件出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22003725/