Arrays of Strings

This is a discussion on Arrays of Strings within the C++ Programming forums, part of the General Programming Boards category; Is it possible for me to have atrrays of strings in C++? For exaple: String[0]="Hello"; String[1]="Goodbye"; String[2]="Catch ya up"; Thanks ...

  1. #1
    Unregistered
    Guest

    Question Arrays of Strings

    Is it possible for me to have atrrays of strings in C++?
    For exaple:

    String[0]="Hello";
    String[1]="Goodbye";
    String[2]="Catch ya up";

    Thanks for any help,
    Paul

  2. #2
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    Code:
    char *myarray[3]={"hello", "goodbye", 
    //...
    is that what you mean?

  3. #3
    Unregistered
    Guest
    But isn't that a pointer?

    Well anyway, using what u said, if I wanted the computer to print "Hello" would I write: cout << Myarray[0] ?
    And what If i only wanted it to print say, the first letter of the Word "hello", how would I go about getting only the first character up?

    Paul

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Try this String[0][0].

    Kuphryn

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    8

    Arrays of pointers to strings

    Yes, you can have pointers to strings and put tghem in an array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 07:37 AM
  2. Replies: 2
    Last Post: 02-23-2004, 06:34 AM
  3. working with strings arrays and pointers
    By Nutka in forum C Programming
    Replies: 4
    Last Post: 10-30-2002, 08:32 PM
  4. strings or character arrays
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 07-21-2002, 11:55 AM
  5. Searching arrays for strings
    By Zaarin in forum C++ Programming
    Replies: 14
    Last Post: 09-03-2001, 07:13 PM

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