Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;程序在编译时崩溃_C++_C++11_Codelite - Fatal编程技术网

C++ C++;程序在编译时崩溃

C++ C++;程序在编译时崩溃,c++,c++11,codelite,C++,C++11,Codelite,这是我的代码。编译完成后,控制台启动,但立即崩溃,说明name.exe已停止工作。警告:扩展初始值设定项列表仅适用于-std=c++11或-std=gnu++11\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ #include<iostream> #include<conio.h> #include<string> //introducing string

这是我的代码。编译完成后,控制台启动,但立即崩溃,说明name.exe已停止工作。警告:扩展初始值设定项列表仅适用于-std=c++11或-std=gnu++11\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#include<iostream>
#include<conio.h>
#include<string> //introducing string classes.
struct cia
{
    std::string name;
    std::string code;
    float balance;
};




int main()
{
   using namespace std;

    cia agent[10] =
    {

     agent[0] =
     {    "wallflower",
         "007860",
         300000
     },

     agent[1] =
     {
         "albus",
         "117861",
         310000
     },

     agent[2] =
     {
         "severus",
         "227862",
         600000
     },

     agent[3] =
     {
         "enigma",
         "337862",
         550000
     },


    };

   string head="\n\t\t\t\t\tCIA";
   string username;
   string pass;


   cout<<head;
   cout<<"\n Welcome To The Most Secure network of Justice.";
   cout<<"Username-; ";
   cin>>username;
   getch();


}
#包括
#包括
#包括//引入字符串类。
结构中央情报局
{
std::字符串名;
std::字符串代码;
浮动天平;
};
int main()
{
使用名称空间std;
中情局特工[10]=
{
代理[0]=
{“墙花”,
"007860",
300000
},
代理人[1]=
{
“阿不思”,
"117861",
310000
},
代理人[2]=
{
“西弗勒斯”,
"227862",
600000
},
代理人[3]=
{
“谜”,
"337862",
550000
},
};
字符串头=“\n\t\t\t\t\tCIA”;
字符串用户名;
串通;

cout代理的定义是错误的。您应该使用以下内容:

    cia agent[4];
     agent[0] =
     {    "wallflower",
         "007860",
         300000
     };

     agent[1] =
     {
         "albus",
         "117861",
         310000
     };

     agent[2] =
     {
         "severus",
         "227862",
         600000
     };

     agent[3] =
     {
         "enigma",
         "337862",
         550000
     };

我认为结构应该是这样的:

cia agent[10] = {
    {"wallflower", "007860, 300000},
    {"albus", "117861", 310000},
     ... and so on
};

程序只有在编译之后才会崩溃。在编译之前,它们不能运行,所以它们不能崩溃。是的,但在编译之后,它会立即停止。我的意思是控制台(cmd)崩溃。你是如何编译程序的?你的编译器命令行是什么样子的?你使用的是什么编译器(以及什么版本)?我正在使用mingw32编译器和codelite作为IDE。我认为您搞错了要执行的操作的语法,最后尝试使用未初始化的数组值初始化数组。请尝试删除
代理[0]=
,等等。