Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: array init'ing, static or auto? Message-ID: <1622@crdos1.crd.ge.COM> Date: 15 Nov 89 14:52:23 GMT References: <2679@dogie.macc.wisc.edu> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 24 If you are not going to modify the char array, by all means make it static. Many compilers will not allow you initialize the array unless it *is* static, although ANSI compilers should. You might want to init to a char pointer, as this takes less time in init, may take more in execution depending on what you do with it; foo() { char str1[] = "abcd"; /* make not work on old compilers */ static char str2[] = "abcd"; /* should be portable */ char *str3 = "abcd"; /* should be portable */ /* code here */ } Note that these are NOT completely the same, although most uses with or without subscripts should generate the same results. There are performance tradeoffs and if you declare an array instead of a pointer you can't modify it (obviously). -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon