Hello! Tell me please:

struct List { char *word; List *next; }; 

I have such a structure. And I need an array of such structures:

 List *list[50] 

How do I refer to the word field in this structure?

 list[iCount].word у меня ошибку выдает *(list + iCount).word тоже не вариант 

Tell me please!

  • Well, what does the list [iCount] -> word disagree with you? (not forgetting to declare word in the public section) - DreamChild
  • why in this case I can not do this action? list [iCount] = list [iCount] .next; After all, with the usual structure of the List * list; list = list-> next works fine - Beraliv
  • are you hinting at the difference of access through a point and ->? Actually, the only difference is that someClass-> someField == (* someClass) .someField - DreamChild
  • Okay thank you. I 'll try to figure it out myself - Beraliv
  • And how to set var l = new List <type> [5]; l [0] .Add (new type {1 = ..., 2 = ..., 3 = ... gives the error Object reference not set to an instance of an object. - VKonstantin

1 answer 1

Well, this can be done in at least two different ways.

The first:

 List list[50]; list[1].word = ""; 

Second:

 List **list = new List *[50]; // субструктура вида: "массив указателей на указатели" list[1]->word = ""; //или: 1[list].word = ""; //или: (list+1)->word = ""; 
  • Thanks :) but I already figured out - Beraliv