-3

I do not know what this is called, I've seen something like it before. Where ever I had seen it, it said that it is not the best approach.

Items[0].x = 0; 
Items[0].y = 0; 
Items[0].width = 32; 
Items[0].height = 32; 
Items[0].name = "RandomName"; 

That is a better example. That is what I am doing. I was hoping there was a way to get around the Items[0]. prefix when entering the information.

Evan Carslake
  • 2,267
  • 15
  • 38
  • 56
  • Do you mean how to initialize structs? – Ivarpoiss Mar 16 '14 at 02:06
  • You might be thinking of designated initializers from C: `struct StructOne test = {.a = 4, .b = 2, .c = 2};` (sorry if that's slightly wrong). However, there's still aggregate initialization: `StructOne test = {4, 2, 2};` and you can compose that with an array's initialization. – chris Mar 16 '14 at 02:09
  • See this http://stackoverflow.com/questions/8534526/how-to-initialize-an-array-of-struct-in-c You may also look up constructors and initializer lists. – Ivarpoiss Mar 16 '14 at 02:12
  • I mean like: `struct a { int b; int c; };` `a test[2];` `with test[0] // the "with" being something else` `b = 5; c = 7;` `with test[1] ` `b = 56; c = 6;` – Evan Carslake Mar 16 '14 at 02:12

2 Answers2

3

CTRL+C then CTRL+V afterwards seems to work for me

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
0

You want something like:

test.a = 4;
test.b = 2;
test.c = 2;
Paul Evans
  • 27,315
  • 3
  • 37
  • 54