Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC830713); site ark.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!mcvax!vu44!botter!ark!huisjes From: huisjes@ark.UUCP (Michiel B. Huisjes) Newsgroups: net.lang.c Subject: Re: String help! Message-ID: <437@ark.UUCP> Date: Sun, 24-Feb-85 07:46:52 EST Article-I.D.: ark.437 Posted: Sun Feb 24 07:46:52 1985 Date-Received: Wed, 27-Feb-85 21:18:27 EST References: <8257@watarts.UUCP> <929@ukma.UUCP> Reply-To: huisjes@ark.UUCP (Michiel Huisjes) Organization: VU Informatica, Amsterdam Lines: 32 Summary: In article <929@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes: >In article <8257@watarts.UUCP> upen@watarts.UUCP (Ue-Li Pen) writes: >> Is it allowed & portable to use the construct: >> char* foo(){ >> return("foobar"); >> } >> This would hopefully return a pointer to the string "foobar".. > >Yes it does....However it is a pointer to a STATIC data area. >So it wouldn't be a good idea to change the contents of the string. >-- >-:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:- >-:-David Herron; David Herron is right, except for the fact that you are allowed to change the contents of the string as long as you don't change the length of it! So you are allowed to say: main() { char *ptr; char *foo(); ptr = foo(); strcpy( ptr, "barfoo" ); ..... } -- Michiel Huisjes. {seismo|decvax|philabs}!mcvax!vu44!ark!huisjes