Path: utzoo!utgpu!attcan!uunet!husc6!bbn!uwmcsd1!ig!agate!ucbvax!decwrl!sun!thetone!swilson From: swilson%thetone@Sun.COM (Scott Wilson) Newsgroups: comp.lang.c Subject: Re: Defining array types in C Keywords: typedef type Message-ID: <62910@sun.uucp> Date: 4 Aug 88 22:24:39 GMT References: <725@arctic.nprdc.arpa> Sender: news@sun.uucp Reply-To: swilson@sun.UUCP (Scott Wilson) Distribution: na Organization: Sun Microsystems, Mountain View Lines: 31 >I would like to define array types in C so that I can declare variables of >those types. The first idea that comes to mind is to use a typedef, yet the >syntax of typedef (and C declarations for that matter) seems to prohibit this. This should do what you want, I think: typedef char name_type[20]; typedef struct person { name_type name; int age; } person; main() { person p; strcpy(p.name, "Joe Schmoe"); p.age = 12; } It sounds like you are a Pascal person who is new to C. The switching of types and variable names confused me for a long time especially when typedefing structs. Often you will see people just use a struct template without actually defining any variables, and this is also confusing. -- Scott Wilson arpa: swilson@sun.com Sun Microsystems uucp: ...!sun!swilson Mt. View, CA