#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    New York
    Posts
    8
    Rep Power
    0

    String arrays and passing them to functions


    PHP Code:
    I have a string array set up to accept student namesI'd like to pass it to a function that would fill in the array with names, and pass it back to the main function.
    Tried setting it up like this:
    #include <string>
    void fill(string array[]);

    main function
    {
    string array[10];

    Call fill(array);
    }
    void fill(string array[])
    {
    ...

    I get an error message on the function prototype line saying
    that "string" is not defined.
    Any suggestions on how to change it, to make it work?
  2. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    try #include<string.h>

    or adding
    using std::string; after <string> if u dont want to include the .h

IMN logo majestic logo threadwatch logo seochat tools logo