This may be a very logical question for someone
trying to teach himself C. Some language constructs
can be quite confusing! But I think *most* good C
programmers have familiarity with machine languages(*)
and therefore visualize s and t as separate memory
words, and see "t = s" and "s++" as simple operations
on these memory words. Conceptual problem disappears!!
Some will say "No, no ... C is defined as an abstract
machine described by legalese English" and I'd need
a lawyer to argue with *them*. The simple fact is that
most good C programmers learned C before the lawyers
took over and visualize explicit machine operations
on the machine's memory words.
(* - one needn't actually learn a machine language.
Programming languages that are almost the same as
machine languages are good enough, e.g. Fortran --
whose name means "FORmula TRANslation to machine
language -- or (donning asbestos suit) ... C!!)
BTW, as a minor nit I *detest* the syntax
char *t = s;
which always causes a mental hiccup, due to the misleading
"*". It's simple shorthand for
char *t;
t = s;
Use the less misleading longhand.
How long does something have to puzzle you before you give it a try
and see what happens?
Excellent point and, again, good programmers learn their
trade with experimentation. I was surprised at the
pedantic responses to Mr. Gamble's post. (I love the
*simplicity* of C, but some pedants seem to thrive on
its perceived complexities, perhaps hoping that misleading
novices will improve their own job security.)
The idea that a novice trying to understand
s = t; s++;
shouldn't build his skill by giving
it a try and see what happens
shows confused and laughable thinking.
James Dow Allen