Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!fernwood!vixie!avsd!childers From: childers@avsd.UUCP (Richard Childers) Newsgroups: comp.lang.c Subject: How Does 'C' Store Strings ? Message-ID: <2141@avsd.UUCP> Date: 11 Oct 89 17:10:35 GMT Reply-To: childers@avsd.UUCP (Richard Childers) Organization: Metaprogrammers International Lines: 39 I'm trying to create a MS-DOS equivalent of the UNIX utility 'strings' - ultimately part of a public-domain package of UNIX utilities that will compile under both MSDOS and UNIX - and I've run into a problem. Basically, no matter how I look at the resulting executable - whether with my 'strings', or a quick-and-dirty 'od' - I can't find the ASCII characters corresponding to the strings I thought I had compiled into the executable. As far as I know, in UNIX, char is stored as individual allocated bytes, perfectly accessible, perfectly in accord with ASCII specifications. I've tried explicitly defining char arrays, IE #define vers[CMDBUFSIZ] = "v1.00 891010 richard childers" ; ... as well as trying to find strings built into fprintf() calls, to no avail. What am I missing ? One of the possibilities I've considered includes the fact that, while I've defined this array, I've never referenced it, and thus the compiler might have decided to optomize it out of existence. Another possibility is that strings found in printf() or fprintf() are compressed. If so, I haven't seen any reference to how this might be turned off, although there are three manuals to peruse. Am I going to have to write a decompression algorithm ? That's going to have to be applied to every byte ? And if I want to bury ID strings in my code, am I going to have to initialize strings on a byte-by-byte basis ? Ay, caramba !! I'm using MicroSoft C v4.00 on a Wyse PC with about 128 KB on board ... -- richard -- * A CITIZEN: "Who might you be ? Samson ? --" * * CYRANO: "Precisely. Would you kindly lend me your jawbone ?" * * from _Cyrano de Bergerac_, by Edmond Rostand * * ..{amdahl|decwrl|octopus|pyramid|ucbvax}!avsd.UUCP!childers *