Hi
I am trying to make arrays inside a structure.. the structure looks like,

struct mystruct{

  int val;
  int num;
  string state[];
  mystruct *next[];

};

The next pointer array works fine but state array gives segmentation fault.

I have an array of this structure .

mystruct Graph [];

Arrays must have a size. If your goal is an array with unknown or variable size, I'd recommend an std::vector:

#include <vector>

struct mystruct {
    int val;
    int num;
    std::vector<std::string> state;
    std::vector<mystruct*> next;
};

<already answered, deleted>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.