Like Tree2Likes
  • 1 Post By grumpy
  • 1 Post By Adak

pointers

This is a discussion on pointers within the C Programming forums, part of the General Programming Boards category; Given the following declarations int i =3, j, *iptr; the following statement is intended to assign value of i to ...

  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,629
    Follow this link, read, and do your own homework.
    dennis.cpp likes this.
    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, Sunshine, 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!
    dennis.cpp likes this.

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, 06:19 AM
  2. Storing function pointers in generic pointers
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 08-01-2009, 02:33 PM
  3. Pointers to pointers in linked lists
    By G4B3 in forum C++ Programming
    Replies: 2
    Last Post: 07-23-2008, 04:54 AM
  4. Pointers to objects -- passing and returning pointers
    By 1veedo in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2008, 12:42 PM
  5. weak pointers and use_count smart pointers
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2006, 08:54 AM

Tags for this Thread


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