Results 1 to 9 of 9

Thread: How about this one

  1. #1

    Thread Starter
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448

    How about this one

    I want to make an array that contains strings... how do I go about this? For example, in Perl I would type:

    @bleh = ("bleh", "blah", "heh", "haha")

    That's what I want... an array with strings... but in C. And how do I declare it?

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    char mystring[len][numwords];
    always worked for me

  3. #3

    Thread Starter
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448
    Does anyone know any tutorials that cover C programming REALLY well... like everything in really great detail. I'm mostly looking for more on strings and arrays. I need a few that are really detailed. Thanks in advance!

  4. #4
    Ya ya Baby!!!Me is Back
    Join Date
    Jul 2002
    Posts
    362
    char cMyArray[2] = {"ok","bye"};

  5. #5
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    you can't store "ok" and "bye" in a character...

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Code:
    #include <string>
    using namespace std;
    
    void main(){
    
    	string str[2] = {"ok", "bye"};
    
    }

  7. #7
    New Member
    Join Date
    Sep 2002
    Posts
    12

    CString

    I would try to avoid using 2 dimensional character arrays for strings.

    Make use of the CString library available.

    CString works for one string, CStringArray works for an array of CString's. If you need more information just ask and I'll be glad to help you out.

  8. #8
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    USE the STL string over a CString, as the STL string will be availible with just about any compiler that is worth its salt.

    Z.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    CString is also only available with either MFC or ATL, both of which will press you into a predetermined application scheme.
    Probably not what you want.

    Use the STL string, maybe the STL vector (some people have problems using a vector of strings).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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