What is a pointer??

Discussion in 'Programming' started by quickwebdesigners, Sep 25, 2007.

  1. #1
    I program in PHP and ASP.NET with C#...

    I am taking a C programming course but I do not know what a pointer is. I'm not sure if I'm just a sucky programmer or what but could someone explain to me in technical terms what a pointer is? :confused:
     
    quickwebdesigners, Sep 25, 2007 IP
  2. lordadel

    lordadel Active Member

    Messages:
    1,035
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    90
    #2
    i am not expert in programming but as i remember it was a variable that holds the "address" of another variable in the memory

    i hope this would help
     
    lordadel, Sep 25, 2007 IP
  3. MarkusJ_NZ

    MarkusJ_NZ Well-Known Member

    Messages:
    240
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Like lordadel said, a pointer is simply a variable which "points" to the location of an object. You can then access the methods, public variables etc of this object via this pointer.
     
    MarkusJ_NZ, Sep 25, 2007 IP
  4. kjewat

    kjewat Active Member

    Messages:
    149
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    kjewat, Sep 25, 2007 IP
  5. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #5
    Pointer is an address of a variable in memory
    int i;
    int *j=&i;
    now j holds the address of i;
     
    it career, Sep 26, 2007 IP
  6. quickwebdesigners

    quickwebdesigners Peon

    Messages:
    106
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    So if you print j, is it some garbage code for the address?
     
    quickwebdesigners, Sep 26, 2007 IP
  7. lordadel

    lordadel Active Member

    Messages:
    1,035
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    90
    #7
    yah it will print the address of i in the memory but it's not garabage ;)
     
    lordadel, Sep 26, 2007 IP