pointers and pointing

Discussion in 'C Programming' started by Bill Cunningham, Apr 21, 2014.

  1. 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
     
    Bill Cunningham, Apr 21, 2014
    #1
    1. Advertisements

  2. 1/10

    You are getting lazy Bill. This is a recycle of your post from Feb.
    10, 2010
     
    Barry Schwarz, Apr 21, 2014
    #2
    1. Advertisements

  3. Give me a link
     
    Bill Cunningham, Apr 21, 2014
    #3
  4. Bill Cunningham

    buja Guest

    buja, Apr 21, 2014
    #4
  5. 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...
     
    Kenny McCormack, Apr 21, 2014
    #5
  6. Bill Cunningham

    Osmium Guest

    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".
     
    Osmium, Apr 21, 2014
    #6
  7. From memory: www.google.com->more->even
    more->groups->comp.lang.c->cunningham and then look for pointers.
     
    Barry Schwarz, Apr 21, 2014
    #7
  8. Bill Cunningham

    jacob navia Guest

    Le 21/04/2014 22:28, Kenny McCormack a écrit :
    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
     
    jacob navia, Apr 21, 2014
    #8
  9. 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.
     
    Bill Cunningham, Apr 21, 2014
    #9
  10. Bill Cunningham

    James Kuyper Guest

    James Kuyper, Apr 21, 2014
    #10
  11. Kenny McCormack, Apr 21, 2014
    #11
  12. 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.
    And yet you keep coming back even though your problems are never
    solved.
     
    Barry Schwarz, Apr 22, 2014
    #12
  13. 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
     
    glen herrmannsfeldt, Apr 22, 2014
    #13
  14. Bill Cunningham

    David Brown Guest

    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.
    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).
     
    David Brown, Apr 22, 2014
    #14
  15. Bill Cunningham

    James Kuyper Guest

    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.
    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.
     
    James Kuyper, Apr 22, 2014
    #15
  16. 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.
    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.
     
    Bill Cunningham, Apr 22, 2014
    #16
  17. Bill Cunningham

    Ken Brody Guest

    On 4/21/2014 4:43 PM, Osmium wrote:
    [...]
    Well, it's obvious that you have no idea. :)
     
    Ken Brody, Apr 22, 2014
    #17
  18. Bill Cunningham

    Ken Brody Guest

    On 4/22/2014 9:37 AM, Bill Cunningham wrote:
    [...]
    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.)
     
    Ken Brody, Apr 22, 2014
    #18
  19. 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
     
    Bill Cunningham, Apr 22, 2014
    #19
  20. Oh yes and PS. I thought &p was passing the address of the pointer?
    We're using different language about the same thing.

    Bill
     
    Bill Cunningham, Apr 22, 2014
    #20
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.