Thread: Array of Strings

  1. #1
    Unregistered
    Guest

    Unhappy Array of Strings

    Could someone please tell me how to declare an array of strings...Sounds stupid but im stumped....!

    thnx,
    Wick

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    What kind of strings do you want? An array of character strings can be defined as a 2d array:

    Code:
    char strings[10][20];

  3. #3
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    Or if you're going to use ANSI string:

    std::string Strings[20];
    Making error is human, but for messing things thoroughly it takes a computer

  4. #4
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    The STL string class is smarter than the character array because it can grow, but if you want it to also be smart due to the fact that you don't know how many strings you need than use containers:
    Code:
    vector<string> strings;
    list<string> strings;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. intializing an array of strings
    By doubty in forum C Programming
    Replies: 4
    Last Post: 06-19-2009, 12:59 PM
  2. Replies: 1
    Last Post: 03-19-2009, 10:56 AM
  3. Build an array of strings dynamically
    By Nazgulled in forum C Programming
    Replies: 29
    Last Post: 04-07-2007, 09:35 PM
  4. Array of strings in C
    By szill in forum C Programming
    Replies: 10
    Last Post: 02-22-2005, 05:03 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM