Filling array of Structs

Hi,
Can somebody please explain how to fill array of structures. I have a USTRUCT with 2 int’s,. Fells like i am missing something or i am stupid.

271209-безымянныи.png

I have set up all variables.

271214-безымянныи3.png

and now i want to fill the GridFormatArray using Add

271215-безымянныи1.png

I have tried several methods, but none of those succeeded
It would be nice if someone can help me out!
Thanks!

Hi.
You didn’t tell what’s wrong with this code, but I suppose if didn’t compile. I think you should add a default constructor to your structure. If you don’t want a constructor, you may use TArray::AddUninitialized or TArray::AddZeroed to add specified number of items, then initialize them explicitly by iterating over array items.

Hi. The problem is much more simple. How to use Add method in this case? I just dont undesrtand what should i type in in Add method in case, when i use array of structs. Thanks for your reply!

Your code should add an uninitialized FAxialCord to your array.

If you do something like:

FAxialCord temp;
temp.q = 1;
temp.r = 2;
GridFormatArray.Add(temp);

You can set the values, but I recommend adding at least a default constructor to your struct.

Got It Thank you!!! And if you ave any Idea how to Find an item through that kind of array can you please share wit me? Thanks! I have posted another question.