Hey guys , i am having a problem with string arrays. Basically ,i declared my array in the header file. Here is my prog.


using namespace std;

int main(){
string Test = "fat";
e te;


class e
    void b(string)
     string a [ ];
     int f;



void e::b (string t)
   e rt;
   rt.f ++;
   rt.a[rt.f] = t;
   cout << rt.a[rt.f] << endl

Okay guys , when i tried this using Netbeans on Windows running on MinGW. But when i tried it on Netbeans in Unix or just compiling using g++ using text editor , i kept on getting segmentation error. I hope for some help regarding this matter.

line 18 in Test.h does not declare an array, but only an uninitialized pointer to an array. Therefore line 30 in Array.cpp will crash because the array has no size. Instead of trying to use an array of std::strings, use a std::vector, e.g. std::vector<std::string> a; Then call vector's push_back() method to add a new string to the end of the array.