Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think!snorkelwacker!bu.edu!purdue!mentor.cc.purdue.edu!g3f From: g3f@mentor.cc.purdue.edu (Wayne Scott) Newsgroups: comp.lang.c Subject: Re: Initilization of global structures Message-ID: <10411@mentor.cc.purdue.edu> Date: 2 May 90 17:27:23 GMT References: <9005020423.AA05715@en.ecn.purdue.edu> Reply-To: g3f@mentor.cc.purdue.edu (Wayne Scott) Organization: Purdue University Lines: 24 In article <9005020423.AA05715@en.ecn.purdue.edu> wscott@EN.ECN.PURDUE.EDU (Wayne H Scott) writes: > >I am having some problems with a program I am writing. This might be very >simple but I can't figure it out. > >I have several global arrays that hold constant information as arrays of >structures. (weapon data, race data, ...) I also have a global array of player >information that has some arrays of number of weapons. The problem I am having >is that I want the compiler to be able to figure out how many weapons are >defined in the structure and use that number to define the player structure. > Perhaps I should have been more clear about what my problem is. I have no problem specifing the starting values for the array. My problem is that I don't want to have a fixed constant for the number of elements in the array. I want the compiler to figure that out. The sizeof trick I used in the posting does that for the globals.c file but the number is not a constant so I can define another structure with a fixed sized array in it. I was sent one reasonable way using alot of preprocessor tricks, but it seems like it should be easier. Wayne Scott wscott@en.ecn.purdue.edu