Thread: *pointers

  1. #1
    Registered User mike's Avatar
    Join Date
    Aug 2001
    Posts
    12

    Question *pointers

    Hi I am new to C++ and I am having trouble with pointers.
    Can someone try and explain it to me so I can understand it.
    Thanks for your time!

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Here's a really good tutorial: http://pweb.netcom.com/~tjensen/ptr/pointers.htm

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    what about pointers dont you understand?

    they are just memory addresses which store other memory addresses rather than values. You can get the value pointed to by dereferencing the pointer by preceeding it with an asterix *

    Code:
    char array[10]={0};
    char* iter=&array; // declare a pointer called iter and point it at the array called array
    *iter='H';// stores 'H' in array[0]
    iter++;// moves pointer to point at array[1]
    *iter='e';
    iter++;
    *iter='l';
    iter++;
    *iter='p';
    printf("%s",array);// should print Help
    Last edited by Stoned_Coder; 08-27-2001 at 09:36 AM.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed