Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pegasus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ahuta!pegasus!hansen From: hansen@pegasus.UUCP (Tony L. Hansen) Newsgroups: net.lang.c Subject: Re: String help! (getting ANSI C strings back out of ROM) Message-ID: <2181@pegasus.UUCP> Date: Mon, 18-Mar-85 23:29:44 EST Article-I.D.: pegasus.2181 Posted: Mon Mar 18 23:29:44 1985 Date-Received: Tue, 19-Mar-85 08:03:03 EST References: <1156@ukma.UUCP> <113@mit-athena.UUCP> <573@rlgvax.UUCP> Organization: AT&T Information Systems, Lincroft NJ Lines: 20 By definition, in ANSI C (according to the latest Feb. draft) string constants are of type "const char[]". The first horrified thought that comes to the mind of many UNIX programmers is "What do I do with all of my calls to mktemp() now?" Easy! mktemp ("/tmp/fooXXXXXX"); becomes mktemp ( (char *) "/tmp/fooXXXXXX"); Since the cast is used withOUT the "const" qualifier, the compiler is forced to place the string in writable memory. Note that I am NOT casting a "char *" back into a "char *", but am instead casting a "const char *" into a "char *". Since the number of times that such idioms will be needed will be very small, this change to ANSI C will definitely be more beneficial than harmful. Tony Hansen pegasus!hansen