Results 1 to 3 of 3

Thread: Strings

  1. #1

    Thread Starter
    Addicted Member jmiller's Avatar
    Join Date
    Jul 2002
    Location
    University of Michigan
    Posts
    238

    Strings

    This is one of those times where i wish i was still programming in VB. I've included the string.h lib, now how do I declare a variable as a string? Actually i want to declare an array of strings, so if you could give me the syntax for that i would much appreciate it.
    thanks
    jmiller

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    string.h is deprecated (sp?). Just use #include <string>
    Code:
    #include <string>
    
    using namespace std;
    
    int main()
    {
        string s[20]; //array of 20 strings (indexes are 0 - 19)
    
        //do something with the strings
    
        return 0;
    }
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Lively Member
    Join Date
    May 2002
    Location
    Oregon
    Posts
    64
    And if you need a dynamic array take a look at vectors. Fairly painless to use.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width