Pointers

This is a discussion on Pointers within the C++ Programming forums, part of the General Programming Boards category; How do you use a pointer to access an entire array or pass an entire array. I know if u ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    1

    Pointers

    How do you use a pointer to access an entire array or pass an entire array. I know if u assign a pointer to an array it only represents the first element.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,734
    Quote Originally Posted by l_starter_l
    How do you use a pointer to access an entire array or pass an entire array. I know if u assign a pointer to an array it only represents the first element.
    Generally, you do not need to use a pointer to point to an entire array. With a pointer to the first element and the size of the array (or a designated end value like a null character), you can traverse over the whole array. I find that a pointer to an actual array comes in handy usually only when you have a multi-dimensional array.

    On the other hand, if you use the standard containers (or a custom container class, for that matter) you generally do not have to worry about the automatic conversion to pointer types that built-in arrays have.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 06:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 12:18 PM

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