Results 1 to 6 of 6

Thread: String Functions

  1. #1

    Thread Starter
    Hyperactive Member Alan777's Avatar
    Join Date
    Jan 2001
    Location
    New Zealand
    Posts
    303

    String Functions

    I'm totally new to C++. Any help is very much appreciated

    Can someone kindly give me C++ equivalents for the following VBA library functions:


    Left <<< Solved
    Right <<< Solved
    Mid <<< Solved
    InStr <<< Solved
    InStrRev
    Len <<< Solved
    Trim

    Looks like by the time someone answers I'll have solved them all myself

    also, how do you make an array of Strings, or do you have to make a 2 dimensional char array for this?
    Last edited by Alan777; Feb 23rd, 2002 at 08:31 AM.

  2. #2
    jim mcnamara
    Guest
    Different classes have different methods. String, Cstring and regular char, are the basic ones.

    C isn't like VB. If you are working on base types like char, you pretty much have only a few string operators available - you get to write your own for most things like LTRIM. String and Cstring have left and right, and so on.

    Go into C++ help, look up string or strcpy. There are a lot of basic string operators. The same applies for String (with a capital S).

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I can remeber at least 3 times someone asked this. Search the forum for trim.
    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.

  4. #4
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Smile Can u pass me the LEFT function...

    Hi Alan,

    Can u please pass me the LEFT function in VC++ or C++ what ever u have...???

    I need it fast...

    Also it will be great if you can send me the whole CPP file with all the declaration and header files include...

    TA.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    string left(const string &s, size_t len) {
        return s.substr(0, len);
    }
    ...or is it (1, len)?...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    it's 0.
    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