Thread: pointers

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    7

    pointers

    Given the following declarations int i =3, j, *iptr;
    the following statement is intended to assign value of i to j
    j = *iptr;
    however this will not work unless preceded by another statment.
    write the required preceding statement.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Follow this link, read, and do your own homework.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Mr.who View Post
    Given the following declarations int i =3, j, *iptr;
    the following statement is intended to assign value of i to j
    j = *iptr;
    however this will not work unless preceded by another statment.
    write the required preceding statement.
    int i = 3 That's perfectly clear
    int j; value of j is uninitialized, could be any whole number atm

    int *iptr; same as j, it has not been given an address yet, could be any address.

    iptr is an address, so what is *iptr? It's the value of what is at that address.

    Which of course, the address of i is what you need. Wouldn't it be handy if we had an address of operator in C?

    Oh, we do!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Storing function pointers in generic pointers
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 08-01-2009, 01:33 PM
  3. Pointers to pointers in linked lists
    By G4B3 in forum C++ Programming
    Replies: 2
    Last Post: 07-23-2008, 03:54 AM
  4. Pointers to objects -- passing and returning pointers
    By 1veedo in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2008, 11:42 AM
  5. weak pointers and use_count smart pointers
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2006, 07:54 AM

Tags for this Thread