pointers and pointing

B

Bill Cunningham

What confuses me the most right now in looking at real world code out
there is this about pointers. When I see a paramter that obvious wants a
pointer, or that's what I believe anyway I don't know how to respond. For
example.

int func(void *par);

Ok I have seen things passed to this type in 3 differnt ways.

int *p;

func(p);

Or

func(*p);

Or

func(&p);

This is what's confusing me now. And I'm getting a lot of error because of
it.

Bill
 
B

Barry Schwarz

What confuses me the most right now in looking at real world code out
there is this about pointers. When I see a paramter that obvious wants a
pointer, or that's what I believe anyway I don't know how to respond. For
example.

int func(void *par);

Ok I have seen things passed to this type in 3 differnt ways.

int *p;

func(p);

Or

func(*p);

Or

func(&p);

This is what's confusing me now. And I'm getting a lot of error because of
it.

1/10

You are getting lazy Bill. This is a recycle of your post from Feb.
10, 2010
 
K

Kenny McCormack

Barry Schwarz said:
You are getting lazy Bill. This is a recycle of your post from Feb.
10, 2010

Just out of curiosity, how did you figure that out?

I used to be able to search groups.google.com (and/or dejanews.com), but
that seems to be no longer working.

Anyway, as I've said before, I'm pretty sure "Bill Cunningham" is a sock
puppet of one of the regs - whose job it is to create activity in this
group.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch [sic] revelations of the childhood
traumas of the participants...
 
O

Osmium

Kenny McCormack said:
Anyway, as I've said before, I'm pretty sure "Bill Cunningham" is a sock
puppet of one of the regs - whose job it is to create activity in this
group.

So "pretty sure" means the same thing as "obvious' in your earlier post?

To me, "obvious" often means the same as "I have no idea".
 
B

Barry Schwarz

Just out of curiosity, how did you figure that out?

I used to be able to search groups.google.com (and/or dejanews.com), but
that seems to be no longer working.

From memory: www.google.com->more->even
more->groups->comp.lang.c->cunningham and then look for pointers.
 
J

jacob navia

Le 21/04/2014 22:28, Kenny McCormack a écrit :
Just out of curiosity, how did you figure that out?

I used to be able to search groups.google.com (and/or dejanews.com), but
that seems to be no longer working.

Anyway, as I've said before, I'm pretty sure "Bill Cunningham" is a sock
puppet of one of the regs - whose job it is to create activity in this
group.

Well, a certain "Bill Cunningham" posted this 5 days ago in
comp.os.linux.development

<quote>
I am using ext4 on my linux. I'm not quite sure of the difference in it
and ext3 but anyway; the shred man page says with the ext3 filesystem shred
cannot be guaranteed to work. What about scrub? What's the best way to
eliminate a file?

Bill
<end quote>

So, he is not trolling in this newsgroup only
 
B

Bill Cunningham

I don't know Barry the thing about clc is that when you ask a question and 3
people respond you will get 3 different answers. And people will lie to you
too with some exceptions. I have had people **** with me and lie about the
way things work. But you must remember the only time you can come to clc for
help is when you do not need it. When there is a *problem* and you have
*solved* it; well then you can come to clc.
 
B

Barry Schwarz

I don't know Barry the thing about clc is that when you ask a question and 3
people respond you will get 3 different answers. And people will lie to you

When you ask a poorly worded question, you should expect a variety of
answers since people will make different assumptions about what you
really meant.
too with some exceptions. I have had people **** with me and lie about the
way things work. But you must remember the only time you can come to clc for

I've seen people post incorrect responses, including myself, without
malice but the only person I've seen deliberately lie here is you.
help is when you do not need it. When there is a *problem* and you have
*solved* it; well then you can come to clc.

And yet you keep coming back even though your problems are never
solved.
 
G

glen herrmannsfeldt

Barry Schwarz said:
On Mon, 21 Apr 2014 18:25:03 -0400, "Bill Cunningham"
When you ask a poorly worded question, you should expect a variety of
answers since people will make different assumptions about what you
really meant.

I have known people to give unusual answers when people ask what
look like homework questions. Not usually wrong, but not always
completely useful.

But I don't remember any such misleading answers in this thread.

-- glen
 
D

David Brown

When you ask a poorly worded question, you should expect a variety of
answers since people will make different assumptions about what you
really meant.

When you ask a well-worded question, you can also often expect a variety
of answers - often there is no simple answer to a good question. And
even if there is only one real answer, different people will express it
in different ways.

The variety of answers you get here is one of the strengths of this group.
I've seen people post incorrect responses, including myself, without
malice but the only person I've seen deliberately lie here is you.

Agreed - lying or deliberately misleading is rare here (except for the
occasional obvious sarcastic reply). There are a few people who are
either deliberately trolling, or determined to remain ignorant no matter
how many times the facts are explained - such posters are arguably
lying, but it is usually quite clear to everyone else where the
consensus opinion lies, so it is not a source of confusion.

And yes, some people make mistakes - even the most experienced C experts
get things wrong on occasion. But typically mistakes get corrected
quickly in this group (that's another of its strengths).
 
J

James Kuyper

I have known people to give unusual answers when people ask what
look like homework questions. Not usually wrong, but not always
completely useful.

In my experience, completely useless and even seriously wrong code is
not an unusual response when someone asks us to do their homework for them.

This should not be confused with proper requests for help with homework,
including explanations of what the poster has already tried to do, and
explanations of what it is they don't understand about why it didn't
work. Such questions generate lots of sincerely helpful responses.
But I don't remember any such misleading answers in this thread.

I can't remember anyone doing anything like that when answering Bill.
The most plausible explanation for Bill that assumes he is a troll, also
implies that he actually understands C far better than he pretends to,
which would render such responses pointless. Those responses are for
lazy clueless newbies, not trolls.
 
B

Bill Cunningham

Barry said:
When you ask a poorly worded question, you should expect a variety of
answers since people will make different assumptions about what you
really meant.


I've seen people post incorrect responses, including myself, without
malice but the only person I've seen deliberately lie here is you.

What did I deliberately lie about. This has been long in the past
someone said to do something when I did they laughed. It didn't work out so
good. That was long ago.
And yet you keep coming back even though your problems are never
solved.

Then I must not have grasped something. People have many times talked
right over my head. I have had a variety of problems yes. Right now my
concern is the difference in pointer notation. If that makes any sense. I've
used it as far as I've do it by following book but I've never understood
fully the power of pointers and how to mechanically use them. Perl and
python do no good in the *nix system interface.

Bill

int *p;

Ok when do I use p and when do I use *p. That right now I am working on.
 
K

Ken Brody

On 4/22/2014 9:37 AM, Bill Cunningham wrote:
[...]
int *p;

Ok when do I use p and when do I use *p. That right now I am working on.

If "p" is a pointer, you use "p" when you want the pointer, and "*p" when
you want what it points to. (And you use "&p" when you want to point to the
pointer.)
 
B

Bill Cunningham

Ken said:
On 4/22/2014 9:37 AM, Bill Cunningham wrote:
[...]
int *p;

Ok when do I use p and when do I use *p. That right now I am working
on.

If "p" is a pointer, you use "p" when you want the pointer, and "*p"
when you want what it points to. (And you use "&p" when you want to
point to the pointer.)

I understood that much. But I think some of the problem with this here
is documentation for certain functions. Docs don't always do well in
explaining what a function wants. Seeing a parameter wants a generic pointer
can mean it wants p or *p or &p. Just depending on the function of the
function. And with a parameter that says void * makes things even worse
because it is written to take any type. I am speaking of getaddrinfo() in
particularly. It deals with struct addrinfo type.

WIth this one mentioned above, you better understand what this function
is all about.

Bill
 
B

Bill Cunningham

Ken said:
If "p" is a pointer, you use "p" when you want the pointer, and "*p"
when you want what it points to. (And you use "&p" when you want to
point to the pointer.)

Oh yes and PS. I thought &p was passing the address of the pointer?
We're using different language about the same thing.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top