Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!barn!everexn!roger From: roger@everexn.uucp (Roger House) Newsgroups: comp.lang.c Subject: Re: typedef-ing an array Message-ID: <1990Jul3.231408.14315@everexn.uucp> Date: 3 Jul 90 23:14:08 GMT References: <78627@srcsip.UUCP> <78633@srcsip.UUCP> Organization: Everex Systems, Inc. Lines: 24 In <78633@srcsip.UUCP> pclark@SRC.Honeywell.COM (Peter Clark) writes: >typedef char foo[29]; >/* a string with 28 chars, add one for the NULL byte */ >foo bar = "Hello World, this is my test"; >void > main() >{ > bar = "Silly old me"; > printf("%s\n",bar); >} >The initializer works fine, but the assignment inside main() doesn't. foo is of type "array of char". The string "Silly old me" is of type "pointer to char". These are two different things. In C you cannot assign a value to an array by using the assignment operator "=". The proper way to do what you are trying to do in the first statement of main is this: strcpy(bar, "Silly old me"); Roger House