Array of string pointers?

This is a discussion on Array of string pointers? within the C++ Programming forums, part of the General Programming Boards category; Code: char *my_array[12]; what exactly does that do? does it create an array of character pointers or a pointer to ...

  1. #1
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640

    Array of string pointers?

    Code:
    char *my_array[12];
    what exactly does that do? does it create an array of character pointers or a pointer to a character array? wha?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It declares an array of pointers to char.

    -Prelude
    My best code is written with the delete key.

  3. #3
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    so how could i make an array of pointers to character arrays?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #4
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    so how could i make an array of pointers to character arrays?
    from this :
    char *my_array[12];

    my_array[0]=new char[99];
    then
    strcpy(my_array[0], "Well, Done!");

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >so how could i make an array of pointers to character arrays?
    Unless my mind has completely left me:
    char *(*array[10])[10];

    will give you an array of 10 pointers to an array of 10 char pointers.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    neandrake: what are you trying to do? Create an array of strings? learn about arrays/pointers? Do you have an example of how you tried to use the line you posted and had trouble using/understanding it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 03:13 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  5. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 05:58 PM

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