Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!princeton!phoenix!rjchen From: rjchen@phoenix.UUCP Newsgroups: comp.lang.c Subject: Re: Unstylish #defines ?? Message-ID: <763@phoenix.PRINCETON.EDU> Date: Thu, 24-Sep-87 16:03:47 EDT Article-I.D.: phoenix.763 Posted: Thu Sep 24 16:03:47 1987 Date-Received: Sat, 26-Sep-87 13:26:10 EDT References: <325@petro.UUCP> Reply-To: rjchen@phoenix.UUCP (Raymond Juimong Chen) Distribution: na Organization: Princeton Univ. Computing and Information Technology Lines: 28 Keywords: quotes, files Summary: ANSI has a better way In article <325@petro.UUCP> jrb@petro.UUCP (Jon Boede) writes: >I've been toying with ways to make the `HOME' directory for a pile of software >a little more portable and the following sure beats the method where you >effectively get -> sprintf(buf,"%s/afile","/usr/me"); fopen(buf,"r"); <- but >it sure does LOOK wierd! > >#define FOO "/usr/me >stream = fopen(FOO/afile","r"); The official ANSI C way of doing it is as follows: #define FOO "/usr/me" stream = fopen(FOO "/afile", "r"); This expands to stream = fopen("/usr/me" "/afile", "r"); which the preprocessor mushes together to make stream = fopen("usr/me/afile", "r") Of course, you need an ANSI-draft-conforming preprocessor first. -- Raymond Chen, BITNET: (preferably) 6101695@pucc, rjchen@pucc ARPA: rjchen@pucc.PRINCETON.EDU UUCP: {allegra}!princeton!pucc!rjchen *** DO NOT REPLACE THIS LINE ***