Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think!mintaka!ogicse!schaefer From: schaefer@ogicse.ogi.edu (Barton E. Schaefer) Newsgroups: comp.lang.c Subject: Re: Initilization of global structures Message-ID: <9036@ogicse.ogi.edu> Date: 2 May 90 16:53:53 GMT References: <9005020423.AA05715@en.ecn.purdue.edu> Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR 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. } } [file=globals.c] } #define MAXNUM 5 } struct weapon { } char *name; } /* etc */ } }; } struct weapon wstats[] = { "knife", "sword" /* etc ... */ }; This is not doing what you think it's doing. The outer set of { } defines the initializer for the array. You need an additional set of { } for each structure-typed element. Try: struct weapon wstats[] = { { "knife", /*etc*/ }, { "sword", /*etc*/ }, /* etc ... */ }; -- Bart Schaefer | The Ultimate Scheme: [apologies to Wadler] | call-cc (lambda (answer) schaefer@cse.ogi.edu | (/ universe (if (= life 0) (answer 42) life)))