How Does 'C' Store Strings ?
Richard Childers
childers at avsd.UUCP
Thu Oct 12 03:10:35 AEST 1989
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 *
More information about the Comp.lang.c
mailing list