Thread: Pointer to array of string and Array of Pointer to String

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    99

    Pointer to array of string and Array of Pointer to String

    Pointer to array of string and Array of Pointer to String refer to the same thing?

    Pointer to array of string - is a 2D array of char

    Code:
    char s[2][3] = {...};
    how to declare a pointer to such an array ?


    Array of Pointer to String

    Code:
    char * s[2][3] = {...};

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Different.

  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
    > Pointer to array of string - is a 2D array of char
    1. What do you regard as being a 'string'. There's no such thing in C unless you declare it.
    2. Your declaration doesn't match the words (in any scenario).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  2. Replies: 10
    Last Post: 11-06-2005, 09:29 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM