Thread: C Pointer Arrays

  1. #1
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507

    C Pointer Arrays

    Are C pointer arrays such as char *myArray[10] equivalent to pointer to pointers? Pointer arrays in general? myArray would be a pointer with 10 elements to other char pointers? Same would be true for any type?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Arrays (whether of pointers or otherwise) are not pointers, but are converted to a pointer to their first element when passed as an argument or used in some other context where a pointer is expected.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Thank you both for your answer, this seems to be cleared up now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  2. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  3. pointer arrays!!!
    By condorx in forum C Programming
    Replies: 1
    Last Post: 05-14-2002, 08:55 AM
  4. pointer arrays
    By condorx in forum C Programming
    Replies: 3
    Last Post: 05-03-2002, 09:04 PM
  5. Replies: 4
    Last Post: 11-05-2001, 02:35 PM