"Ross" <ro************@yahoo.co.uk> wrote
I have a quick question regarding printing string constants. When you
printf() a string constant, how are the characters encoded that get
sent to the standard output? Is it in the execution character set?
That's right.
Normally C source is written in ASCII, and generally C programs use ASCII
internally as their execution set. A few years ago I would have said "most
machines are ASCII" but the concept of an "ASCII machine" has become a bit
fuzzier since then.
Occasionally you might have a C source, but compile for a machine with a
funny character set. So the source file
printf("Hello world\n");
contains the ASCII values 72, 101, 108, 108, etc, along with ASCII values
for the quote,34 paretheses 40, 41, and so on.
Our funny system uses 100 for A, 101 for B, 200 for a 201 for b and so on.
So when we compile, the string "Hello world\n" is laid out in memory as 107,
204, 211, 211 etc. These values are passed to printf(), and by some magic
the glyphs appear in shining pixels on the screen.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $7.20 paper, available
www.lulu.com/bgy1mm