Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
September 14, 2004 array of structures? | ||||
---|---|---|---|---|
| ||||
Hi there, I want to code an array of strcucts and initialize it like this <code> struct person { char[] name; int id; } person[] persons = { [ "Person" , 1 ] ... } but the compiler give the following error a struct is not a valid initializer of person[] how can i solve this. |
September 14, 2004 Re: array of structures? | ||||
---|---|---|---|---|
| ||||
Posted in reply to aelmetwaly | aelmetwaly wrote: > Hi there, > I want to code an array of strcucts and initialize it like this <snip> > but the compiler give the following error > > a struct is not a valid initializer of person[] > > how can i solve this. You've got your {} and [] backwards? Should be person[] persons = [ { "Person" , 1 } ... ]; Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
September 21, 2004 Re: array of structures? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | In article <ci6ugd$2t1i$1@digitaldaemon.com>, Stewart Gordon <smjg_1998@yahoo.com> wrote: > aelmetwaly wrote: > > Hi there, > > I want to code an array of strcucts and initialize it like this > <snip> > > but the compiler give the following error > > > > a struct is not a valid initializer of person[] > > > > how can i solve this. > > You've got your {} and [] backwards? > > Should be > > person[] persons = > [ > { "Person" , 1 } > ... > ]; > > Stewart. I find this whole usage of [ ]'s as part of initializers to be confusing. Why is it different from C again? For those of us who missed the discussion before. |
October 29, 2004 Re: array of structures? | ||||
---|---|---|---|---|
| ||||
Posted in reply to aelmetwaly | I encountered this problem too. how to solve? |
Copyright © 1999-2021 by the D Language Foundation