c++ - 编译后可执行文件出错

标签 c++ windows

你能帮我解决我代码中的问题吗?

程序应该要求用户输入狗的名字,最后打印出第三只狗的名字。当我编译和执行该程序时,它说“它停止工作”并且 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/

相关文章:

c++ - 如果该类不是 `copy constructor`,是否可以移动对象?

windows - UTF-16 perl 输入输出

c# - 使用 Javascript 或 Web 表单的 Web 爬网站点

windows - mac pkg 等效于 windows 使 iTunes 文件共享接受文件夹

windows - 在后台使用plink转发本地端口并在本地计算机上执行命令

c++ - 使用远程线程的自由库

C++ 构造函数 : garbage while initialization of const reference

c++ - 另一个 undefined reference 错误

c++ - Xcode 4 mach-o 错误

Windows 计算机分析器