473,842 Members | 1,917 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
Joona I Palaste <pa*****@cc.hel sinki.fi> writes:
Richard Heathfield <do******@addre ss.co.uk.invali d> scribbled the following:
goose wrote:
Mark McIntyre <ma**********@s pamcop.net> wrote in message
news:<hp******* *************** **********@4ax. com>...

And are functions objects?

iirc, yes.

YRI.


TIWITAW.


W?

--
Keith Thompson (The_Other_Keit h) ks*@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 13 '05 #281

On Wed, 5 Nov 2003, Irrwahn Grausewitz wrote:

ru**@webmail.co .za (goose) wrote:

(btw: "roose" is an intentional troll, ever considered that
"roose" is just a mispelled "ruse"?)


Yes, I did indeed, but ruse's and Roose's postings are definitely of
different style. And I do not consider either one to be smart enough
to successfully pretend to be somebody else.

Remember ruse: "... again, spoke your nose!" makes me still ROFL. :D


No, that one was ROSY. Google "spoke ur nose"... :-)
I don't think we've ever had a troll named "ruse."
http://dictionary.reference.com/search?q=ruse

-Arthur,
maybe it *is* best not 2 spoke my nose on this matter
Nov 13 '05 #282
Keith Thompson <ks*@cts.com> scribbled the following:
Joona I Palaste <pa*****@cc.hel sinki.fi> writes:
Richard Heathfield <do******@addre ss.co.uk.invali d> scribbled the following:
> goose wrote:
>> Mark McIntyre <ma**********@s pamcop.net> wrote in message
>> news:<hp******* *************** **********@4ax. com>...
>>>
>>> And are functions objects?
>>
>> iirc, yes.
> YRI.


TIWITAW.

W?


That Is What I Thought As Well.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"As we all know, the hardware for the PC is great, but the software sucks."
- Petro Tyschtschenko
Nov 13 '05 #283
On Wed, 05 Nov 2003 01:46:09 GMT, in comp.lang.c , pete
<pf*****@mindsp ring.com> wrote:
int a;
&a;

(&a) is a pointer, but not an object.


I disagree. (&a) in that context is an expression. To be a pointer, it
would have to be stored in something. .
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #284
On Wed, 5 Nov 2003 01:46:39 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:
int i = 6;
int * const p = &i; /* p is not a variable - or at least, to persuade anyone
that it is, you'd have to have kissed the Blarney. */


Actually p is a variable. It merely happens to have an immutable
value. :-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #285
Mark McIntyre <ma**********@s pamcop.net> scribbled the following:
On Wed, 05 Nov 2003 01:46:09 GMT, in comp.lang.c , pete
<pf*****@mindsp ring.com> wrote:
int a;
&a;

(&a) is a pointer, but not an object.
I disagree. (&a) in that context is an expression. To be a pointer, it
would have to be stored in something. .


This depends on the definition of a "pointer". Is it a value or a
variable?

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The trouble with the French is they don't have a word for entrepreneur."
- George Bush
Nov 13 '05 #286
Mark McIntyre wrote:

On Wed, 05 Nov 2003 01:46:09 GMT, in comp.lang.c , pete
<pf*****@mindsp ring.com> wrote:
int a;
&a;

(&a) is a pointer, but not an object.
I disagree. (&a) in that context is an expression.


Being an expression, doesn't make it not a pointer.
It's a pointer expression.
To be a pointer, it
would have to be stored in something.


That would be a pointer object.
A reference to a pointer object, would be an expression too.

'1' is an integer expression.
'1' is an integer, isn't it ?

--
pete
Nov 13 '05 #287
On Wed, 05 Nov 2003 07:10:34 GMT, in comp.lang.c , "Roose"
<no****@nospam. nospam> wrote:

"Keith Thompson" <ks*@cts.com> wrote in message
news:lz******* *****@cts.com.. .
portable code really isn't all that difficult. But when you write
code that depends on the characteristics of a particular system,
you've left the scope of this newsgroup, and if you have any questions
about it, you're more likely to get correct answers in a newsgroup
devoted to that system.
I can agree with that, but my impression is that this reasonable stance is
not the one that the majority of those in this newsgroup take.


Eh? Its /precisely/ the reasonable stance that teh majority of us
take. You're the one that has a problem with it.
> Can you explain how an error in not writing standard C might result in such
> a bug?


Not specifically, but imagine a program that operates on a pointer in
a manner that only works if pointers are just integers.


I undestand this, but again my contention is that such bugs would be quite
obvious.


You're quite wrong. Elsethread an example of where your idea fails
even for a single architecture has been presented.

You should /never/ make platform specific assumptions in code you plan
to port, and you should avoid making platform specific assumptions
elsewhere except when you actually need to. Thats how you avoid bugs
like this.
Code that depends on this simply would not work when ported and
tested for this first time.
It might work, but have an obscure bug. For example, I once ported a
DVI2HP implementation from Unix to MS-DOS. If you know DVI, you'll
know that its essentially a binary file format for printing, and
consists of encoded instructions telling the print engine where to
place the cursor, what font to use, what colour, how long a line will
be drawn and at what angle etc.

The original implementor read blocks of data from the DVI file using
fread, and generally was a good boy, but very occasionally assumed
that sizeof(int) was the same as sizeof(long). On MSDOS it wasn't.
This obscurely broke the code when very specific DVI was encountered,
as too little data was read. This DVI happened to be rarely used, and
the obscure break was something like picking the wrong colour, or
drawing a line too short. So this went entirely unnoticed during
testing.
But my larger point stands, that for pedagogical purposes, it is a useful,
concrete statement to say that a pointer is not unlike an array index.
Except that array indices need not be integers. Consider library
shelves using the Dewey system, C++ vectors etc. Consider MS-DOS's
segmented architecture, where a pointer was two integers.
An integer. Yes there can be other bits set, and so forth. But if you were a
C programmer who was NOT aware of this fact, I would seriously question you.


Many are when they start out. They only learn it by being told the
right answer, instead of an erroneous concept.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #288

On Wed, 5 Nov 2003, Sheldon Simms wrote:

Also, I think there is an important difference between the concepts
of "variable" and "object". A variable is a named, typed, object.
I'd say that's correct.
An object is, by itself, only storage. It can store a value, but
doesn't have any inherent type or name.


The Standard says that an object has a type. Why else would we
discuss "objects of type T" and "objects of type U"?

So in my little hierarchy of abstractions, I would stick another
one on the bottom: "memory." Objects are kind of "chunks" of
memory, which have types. Memory itself is just a bunch of bytes,
without type information attached.
'malloc' and friends notably return pointers to memory, not
pointers to objects. The program can *access* parts of that memory
as if they were objects of a given type, e.g.:

void *p = malloc(42);
int q = *(int *)p; /* treat the space pointed to by 'p' as
* if it were an object of type 'int' */

The idea of a "typeless" object is meaningless -- all objects
have sizes, for example, and what's the size of an object without
a type? If I write

int i = 42;
void *p = &i;

then 'p' does not have the type 'pointer to object of type X' for
any X -- i.e., 'p' doesn't have any information about the type of
the object to which it points -- but it's still actually pointing
to an object of type 'int': namely, 'i'.

Summary:
Variables have names (but I wouldn't use that word myself).
Objects have addresses, types, and sizes.
Memory (or "space") is typeless and composed only of bytes.

my $.02,
-Arthur
Nov 13 '05 #289
On Wed, 05 Nov 2003 12:27:21 -0500, in comp.lang.c , Sheldon Simms
<sh**********@y ahoo.com> wrote:
On Wed, 05 Nov 2003 14:30:33 +0000, pete wrote:
goose wrote:

Mark McIntyre <ma**********@s pamcop.net> wrote in message news:<hp******* *************** **********@4ax. com>...
> On Tue, 4 Nov 2003 06:28:29 +0000 (UTC), in comp.lang.c , Richard
> Heathfield <do******@addre ss.co.uk.invali d> wrote:
>
> >Sheldon Simms wrote:
> >

(lots of ramble)

and now we know why newbies think pointers are tricksy, wicked or
false....
:-)

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #290

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.