array of strings

This is a discussion on array of strings within the C++ Programming forums, part of the General Programming Boards category; -Can anyone give an example of a program that fills an array with words or names? and if anyone can ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    5

    Post array of strings

    -Can anyone give an example of a program that fills an array with words or names?
    and if anyone can use the AP class subsets that would be great. thanks

  2. #2
    Seņor Member
    Join Date
    Jan 2002
    Posts
    561
    I'm not to sure about what you are asking, but I'll give it a shot.

    #include<apstring.h>
    #include<apvecor.h>

    void main ()
    {
    apvector<apstring>array (4,0);
    array[3]="three";
    array[2]="string";
    }

    Something like that? Or do you mean make up it's own words?

  3. #3
    Unregistered
    Guest
    using apstring it would look something like this...

    your #includes up here...

    const int MAX_SIZE = 10; // the max # of apstrings in the array
    typedef apstring Array_Name[MAX_SIZE]; // the array Array_Name here

    int main()
    {

    // loop to fill each string in the array
    for (int x=0; x<MAX_SIZE; x++)
    Array_Name[x] = "something"; // fills each string in the array with "something"

    return 0;
    } // main


    I think thats what you were asking. If not, oh well. If you wanted to ask the user what they would like to put in the array just throw in some cout/cin lines inside the loop.

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, 01:59 PM
  2. Replies: 1
    Last Post: 03-19-2009, 11:56 AM
  3. Build an array of strings dynamically
    By Nazgulled in forum C Programming
    Replies: 29
    Last Post: 04-07-2007, 10: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, 10:48 AM

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