Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!medar!jseymour From: jseymour@medar.com (James Seymour) Newsgroups: comp.sys.amiga.programmer Subject: Re: ANOTHER SAS C BUG Message-ID: <98@hdwr1.medar.com> Date: 1 Apr 91 17:38:18 GMT References: <1991Mar31.035009.13183@csis.dit.csiro.au> <1991Apr1.050544.13878@cs.cornell.edu> Organization: Medar, Inc. Farmington Hills, MI Lines: 34 In article <1991Apr1.050544.13878@cs.cornell.edu> johnhlee@cs.cornell.edu (John H. Lee) writes: > > [stuff deleted] >By the way, your first statement should read: > > char str[]="hello\n"; > ... (but the amount of >memory allocated is the same.) John, you are correct in that what the original poster was complaining about is, indeed, a portability "bug". You are incorrect regarding your comment on how the string should be declared however (does this belong in the C newsgroup?). char *str = "hello"; /* declare a pointer to a char array, initialize pointer to a string */ char str[] = "hello"; /* declare a character array, initialized in length and contents */ BIG difference. Especially if a function in another function is told that str *contains* a pointer to char, when in reality it *is* the start of the character array itself. [I've bitten myself with that one more times than I'd care to count :-)]. Lastly, the amount of memory consumed is not the same for each. The first declaration takes up more memory than the second (although generally this is an insignificant point). Which way it should be declared depends on what the program[mer] needs. -- Jim Seymour | Medar, Inc. ...!uunet!medar!jseymour | 38700 Grand River Ave. jseymour@medar.com | Farmington Hills, MI. 48331 CIS: 72730,1166 GEnie: jseymour | FAX: (313)477-8897