Website tutorials (Pointers quiz)

This is a discussion on Website tutorials (Pointers quiz) within the C++ Programming forums, part of the General Programming Boards category; Hello all, I'm pretty new here, in fact, I'm as new as they get. I hope to become a more ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    9

    Website tutorials (Pointers quiz)

    Hello all, I'm pretty new here, in fact, I'm as new as they get. I hope to become a more familiar face around here as time goes by, anyway, that's all off topic.

    I'v been going through the tutorials on the main website (which is rediculously awesome, mad props for that), aswell as the quizes, which also really help a lot. Now I only started yesterday, so please excuse me for not having gotten all too far yet.

    Anyway, I was working on the quiz regarding pointers (http://www.cprogramming.com/tutorial/quiz/quiz6.html)

    And I found that when you click the "Anwser key" button, question 3 is different going from the question to the anwser.

    I'm guessing this is just a small error, and I'm not at all sure if I should be posting it in this forum. Though I did figure it would be useful to post, or atleast let the right people know.

  2. #2
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    It's the right answer.

    As I mentioned, there are two ways to use the pointer to access information: it is possible to have it give the actual address to another variable. To do so, simply use the name of the pointer without the *.
    That was from the tutorial you gave the link to.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    9
    Quote Originally Posted by beene View Post
    It's the right answer.



    That was from the tutorial you gave the link to.
    The problem is more so that the "question" goes from:
    3. Which of the following gives the memory address of a variable pointed to by pointer a?
    To:

    3. Which of the following gives the memory address of a pointer a?
    For the above, my guess would be "a;", the lower should be "&a;", am I still right there?
    (the problem is that the questions are different, but shouldnt be)
    Last edited by TheUnknownFacto; 04-18-2007 at 10:11 AM.

  4. #4
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    It doesn't matter, it will still give the same result.

    The memory address that the pointer holds is the same as the pointers memory address.

    So...
    Code:
    int *p;
    int a;
    p = &a;
    cout << *p;
    cout << a;
    ...give out the same result.

    I hope i understood your post right.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    3. Which of the following gives the memory address of a pointer a?
    This is indeed somewhat ambiguous. I'd interpret it like the OP, as &a, i.e. the address of the pointer variable, not the address the pointer variable holds.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    9
    Quote Originally Posted by beene View Post
    It doesn't matter, it will still give the same result.

    The memory address that the pointer holds is the same as the pointers memory address.

    So...
    Code:
    int *p;
    int a;
    p = &a;
    cout << *p;
    cout << a;
    ...give out the same result.

    I hope i understood your post right.
    Correct me if I'm wrong, but pointers do not only store memory addresses, but are also stored at a memory address, so reading the question the way it's writting in the "shorter" form (The way it's given when you click the anwser key link), they're asking for the address of the pointer, not for the address stored within the pointer. Which should be &a;, either way, I don't know who created the tutorials and quiz's (whoever did significantly rocks), but the problem should still be fixed.
    Last edited by TheUnknownFacto; 04-18-2007 at 11:29 AM.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    I've noticed several discreprencies between the quizes and the answers. The only one I can remember at the moment is that one of the questions starts with "Spell Stroustroup. Just kidding." whereas the question in the answers, if you know what I mean, does not.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 11:56 AM
  2. Replies: 4
    Last Post: 09-24-2002, 06:20 PM
  3. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 07:53 PM
  4. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 10:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21