How Does 'C' Store Strings ?

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Fri Oct 13 01:21:45 AEST 1989


In article <2141 at avsd.UUCP>, childers at avsd.UUCP (Richard Childers) writes:

|  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 ?

  You may have two problems here. One is that something defined to the
preprocessor via #define never makes it into the program unless you use
it. One way to define your string is to do something like:

	char *my_id = "The string you want, like copyright";

  I make mine static, but I think it would be legal for a compiler to
optimize out an unreferenced static.

  If you can't find strings which are formats of printfs you may have a
broken "strings." I have used the one I have and it works for MSC and TC
at least.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list