linux - Segmentation fault (core dumped) Error Message during c++ code compilation -


i new c++ , trying compile simple c++ programm. using vector

#include <iostream> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define bufsize 100  using namespace std;  typedef struct aa{     int a;     std::string a_str; }a; typedef struct bb{     int b;     std::string b_str;     vector<aa> aobj; }b;  int main() {   b bobj;   bobj.aobj[0].a=4;   bobj.aobj[0].a_str="dicom";   bobj.b_str="ldap";   bobj.b_str="dicom";   size_t ipos;   ipos=bobj.aobj[0].a_str.find("com");   if(ipos!=string::npos)         cout<<"string found successfully....";   else         cout<<"string not found ....";   return 0; } 

when compile program shows error message segmentation fault (core dumped) using ubuntu os

what need first create object of type aa , push vector of b as

aa aa; aa.a = 4; aa.a_str = "hello world"; bobj.aobj.push_back(aa); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -