Thread: some major pointers/dynamic array help needed

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    5

    some major pointers/dynamic array help needed

    Hi. I'm taking a c++ course at school right now and I'm really confused about these pointers with * and & and stuff... I don't know how to explain it but I've read the tutorial here and tutorial on another site and even my textbook from school... but it's still confusing. I don't think this topic is supposed to be hard cause everyone else seems to get it..

    can someone just explain it in depth to me plz in an easy way? Like:

    int a;
    int *b;

    i don't know when to use a, &a, b, *b, &b, etc... it's a little wierd.. I know '*b' is supposed to piont to something but what about 'b'. can you set 'b' equal to something.. then what about 'a'?

    I know I don't make much sense but I need all the help I can get. I'm struggling in my class. thanks.

  2. #2
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    Do not feel alone.
    I had a rough time with pointers.
    The only thing I can suggest is to keep reading.

    A pointer is an adress to the value pointed to.
    Code:
    int *Bptr; //allocates memory to store address
    
    int c=0;//allocates memory for integer
    
    Bptr=&c;//assigns the pointer the address of integer c
    
    *Bptr=1;// assigns the value of 1 to integer c
    I do not have a compiler handy, but I think this is correct.
    check out this site i pulled out of google.
    http://www.cplusplus.com/doc/tutorial/tut3-3.html
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. Modify an single passed array element
    By swgh in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 08:58 AM
  4. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM
  5. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM