473,842 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Mastering C Pointers"....

Hey guys, I'm new here, just a simple question.

I'm learning to Program in C, and I was recommended a book called,
"Mastering C Pointers", just asking if any of you have read it,
and if it's worth the $25USD.

I'm just looking for a book on Pointers, because from what I've
read it's one of the toughest topics to understand.

thanks in advanced.

sincerely ... Andy
Nov 13 '05
388 21968
Roose wrote:
Sheldon Simms wrote (attribution restored):
I don't know why you are learning C, but lets imagine that
you might someday want to program professionally using C. If
so, you might find it professionally embarrassing when your
code crashes the airplane, cash register, medical device,
file server, robot, etc. because you assumed that a pointer
is "just an integer", as Roose urged you to.
This is a straw man. Any program, of critical nature or not,
is tested, and these types of errors don't even take testers
to figure out.


It's not a "straw man" to those who actually develop such
systems, however. Sticking to Sheldon's examples: I've written
code that flies in the McDonnell Douglas MD11, code that
controlled communications for NASA's TIROS-N boost (launch) and
orbital modes, code that performs fast and precise chemical
analysis of any human body fluid for medical diagnosis, code that
determines whether a merchant should accept your check in payment
for goods/services, and code that performs equity and option
trades on a major stock exchange. I can assure you from first
hand experience that my entire perspective was considerably
changed by accepting responsibility for the lives and well-being
of more people than I will ever even /meet/ in my lifetime.
The code simply won't work when you try it for the first time.
If you want to make an error-free program for one device, it
is probably safer to find out the specifics of your hardware,
and program to that. Rather than coding in 100% "standard
ANSI C" and hoping the compiler does the right thing. If not,
then it will at least save you a lot of time.


It's a good thought - but Murphy says otherwise. I'll be happy to
provide you with specific examples if you really need them.

The language standard isn't there to be opressively restrictive
(my own initial impression!) but to provide a base level
commonality of understanding between compiler writers and
compiler users. It's not sufficient to merely hope that the
compiler does the right thing - it's an /absolute requirement/.
While it may not be apparent from a games perspective, lives and
fortunes depend on that requirement being met.

But if one ventures outside that realm of understanding codified
by the standard, then the amount of risk introduced becomes huge.
Undefined behavior, even when it produces hoped-for results in
the specific conditions tested, may produce totally unacceptable
results if even a single new condition is introduced.
Implementation defined behavior is subject to change with a new
compiler version or a change in compiler vendor. Any such change
introduces the risk of an unacceptable result. The only way a
programmer can influence that risk is to avoid implementation
defined behavior altogether.

The responsible programmer must be aware of the risks and to do
that must know what's nailed down by the standard, what's
implementation defined, and what constitutes undefined behavior.
Perhaps you think that's just hypothetical, that you'll
worry about the details when you know C better. Well that
might work, but on the other hand, I have seen things like
that happen (well, nothing as dramatic as a plane crash)
because the programmer didn't *really* know how C worked.


Again, this pretty much has nothing to do with the C language,
and is more of a QA question.


I sincerely hope you take time to pause and reconsider this
assertion. It /is/ a QA question; but it also has a /lot/ to do
with detailed knowledge of the language used (C or otherwise).
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall very far from the tree.

Nov 13 '05 #171

"Mark McIntyre" <ma**********@s pamcop.net> wrote in message
news:vl******** *************** *********@4ax.c om...
On Tue, 04 Nov 2003 00:01:25 GMT, in comp.lang.c , "BruceS"
<no****@nospam. net> wrote:
Is it a British thing, or have you really never
been in the second year of secondary school or college?


I'm sure Richard has been a second year. At most secondary schools,
thats called "being a second year". At twelve, fancy names tend to be
avoided. Admittedly at my school it was called "being in Shell" but
thats another story.
At college its called "being a second year". First years are freshers,
third years are finalists unless they're doing mod lang, in which case
they're abroad, groping foreign 6th formers, or Divvers, in which case
they're drunk.

(IOW Sophomore is an americanism not in use over here...)


I'd hoped that was the case. Thanks for the clarification.
Nov 13 '05 #172
On Tue, 04 Nov 2003 00:59:05 GMT, Alan Connor <zz****@xxx.yyy > wrote:
On Mon, 03 Nov 2003 16:33:37 -0600, Morris Dovey <mr*****@iedu.c om> wrote:


Alan Connor wrote:
Well, you just crossed the line with that bit of deceitful and sophomoric
trolling.

Killfiled for N days.
<snip>Fine. If you launch a smear campaign against anyone here, I will be
happy to killfile your ass.


Because of the last couple of messages, I've just reviewed your
postings to the group. It seems that you've insulted the regulars,
including a few world-class experts, encouraged the current resident
troll, threatened to killfile anyone who doesn't quite meet your
expectations (do you really imagine they care?) and claimed you
couldn't understand explanations which were precise and on-topic.
Perhaps you would be better served in alt.com.lang.le arn.c-c++.

As for this group, I suggest you just killfile everyone except Roose.
Bye.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 13 '05 #173
Roose <no****@nospam. nospam> wrote:
Let me just dispatch all of these flames toward Alan about me being a troll,
and his judgement and whatnot, with one comment...


Just wanted to mention that while these people are willing to restrict
their assault on you to this newsgroup, they can be extremely vindictive
and are willing to take this assault beyond the confines of USENET
should you persist.

Whether you like it or not Richard H, et. al. are well respected and
influential C programmers and are willing to use this respect and
influence to smack other people down when they see fit.

You cannot win. You will only harm yourself. They will not stop.
--
Nov 13 '05 #174
te*********@bus thotmaile.rcom scribbled the following:
Roose <no****@nospam. nospam> wrote:
Let me just dispatch all of these flames toward Alan about me being a troll,
and his judgement and whatnot, with one comment...
Just wanted to mention that while these people are willing to restrict
their assault on you to this newsgroup, they can be extremely vindictive
and are willing to take this assault beyond the confines of USENET
should you persist. Whether you like it or not Richard H, et. al. are well respected and
influential C programmers and are willing to use this respect and
influence to smack other people down when they see fit. You cannot win. You will only harm yourself. They will not stop.


What in the bloody blazes are you babbling about? You make it sound like
we have some sort personal vendetta against Roose, and would assault him
*in real life* if we ever met him. You must have us confused with the
mafia.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You will be given the plague."
- Montgomery Burns
Nov 13 '05 #175
Roose wrote:
After reading the first 1/3 carefully, it seems to me that a
pointer is very much like a symlink.


Uh, I'm not exactly sure what a symlink is, but if it is anything
like a Windows shortcut, there is definitely an analogy there.

The windows shortcut just stores the location of a file. A
"pointer" to it. An address. The address is the _path name_. In
C, the "address" is basically an integer, indicating where in a
huge array of memory the variable is.


Wrong again, or at least over simplified. Apart from the fact
that you can express any collection of bits as an integer of some
size or other, nothing specifies the makeup of a pointer. It can
be a scrap of paper that says "look in Annies right hand", for all
you know. However, it must have certain properties, and those are
spelled out in the C standard.

On the other hand, if the machine has a linear address space, a
pointer might very well be implemented FOR THAT MACHINE as an
integer in the range of that address space.

There are many properties of integers that pointers do not have.
For an elementary example, you cannot add two pointers. However,
under certain restrictions, you can subtract one pointer from
another and get an integer. But it probably won't be the integer
you expect, unless you understand the rules in the first place.
So for an initial look, assume that "Here there be dragons", and
that they consider you a crunchy tasty morsel.

So my advice to the OP (whom you quoted, but rudely snipped any
attribution for) is to learn the first few rules for working with
pointers and don't try to stretch them without a fuller
understanding. Pointers can be created in various ways,
incremented and decremented, and sometimes compared for equality.
If they are valid they can be dereferenced.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #176
Roose wrote:
.... snip ...
OK, suppose you want to serialize a group of structs, which
contain pointers to each other (a graph). In game programming,
for getting data into the game, it's a common idiom to subtract
the base address in the PC tools, store it on disk, and rebind
the pointers at runtime in the game engine by adding back a new
base address. You can't do that without understanding the
equivalence, since of course you only read ints from binary
files at first.

Of course this is not portable, but it works on 3 game consoles,
and I would contend that there is way to the exact same thing on
ANY platform (with the bit masking/arithmetic being slightly
different, etc.)


Yet, by knowing the true properties of pointers, it is quite
possible to serialize that entire graph, store it, and later
restore it in a completely portable manner. It may take a little
longer, but that is the nature of avoiding dangerous shortcuts.

Just consider a system where multiple processes are occurring, so
that the pointers returned by malloc are not self-consistent
within any single process. This will violently point out that
pointers are not integers.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #177
On 2003-11-04, Roose <no****@nospam. nospam> wrote:
"Keith Thompson" <ks*@cts.com> wrote in message
news:lz******** ****@cts.com...
Testing can only demonstrate the presence of bugs; it can't prove
their absence. There are plenty of bugs that only appear under
unusual circumstances. Pointer bugs can easily cause sporadic
failures that might be missed by testing. Imagine a bug that only
shows up when an airplane does a 10 degree left bank between 28,000
and 30,000 feet during a daylight saving time transition in a location
where true and magnetic north differ by 2 degrees. (That scenario is
purely a product of my imagination).


Can you explain how an error in not writing standard C might result in such
a bug?


If the non-standard C code exists in a code path that was only triggered
under that scenario.

-- James
Nov 13 '05 #178
Irrwahn Grausewitz wrote:

Alan Connor <zz****@xxx.yyy > wrote:

<snip>
Please fix your sig, Lew. It's over 4 lines and I'll have to killfile you
for 30 days if I see it again.


Oh, how threatening. Nobody here cares about trolls plonking
respectable and responsible posters in favour of other trolls.
Honestly.

Alan is actually correct about that. As the .sig has a couple blank
lines in it, it could be brought up to code with no loss of content.


Brian Rodenborn
Nov 13 '05 #179
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
te*********@bus thotmaile.rcom scribbled the following:

<snip>
Whether you like it or not Richard H, et. al. are well respected and
influential C programmers and are willing to use this respect and
influence to smack other people down when they see fit.

You cannot win. You will only harm yourself. They will not stop.


What in the bloody blazes are you babbling about? You make it sound like
we have some sort personal vendetta against Roose, and would assault him
*in real life* if we ever met him. You must have us confused with the
mafia.


<OT humor(?)>

But Joona, c.l.c /is/ the mafia, look at some of the names (picked
randomly, in no particular order):

Dan "Don" Pop
Richard "The Voice" Heathfield
Joona "Joker" I Palaste
Chuck "Berserk" Falconer
Nobody "Nobody" Nobody
Chris "The Rule" Torek
Mike "Smiley" Wahler
Default "Nuke'm" User
James "Brains" Kuyper
Irrwahn "Germ" Grausewitz
...
[ continue at will ;-) ]

</OT humor(?)>

Damn, didn't I promise to not post further in this thread? Oh, too
late, too late ...
--
Irrwahn
(ir*******@free net.de)
Nov 13 '05 #180

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.