Thread: Left, Right of char arrays

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    19

    Left, Right of char arrays

    In VB (yes, I'm a Visual Basic programmer switching to C++), there are a few functions I use which I cannot seem to find in C++ libraries. They are: Mid(), Left() and Right().

    Left will extract text from the left part of a string, Right will take it off of the right. For example, Left("Hello", 2) will return "He". Right("Hello", 2) will return "lo". Mid() will take text from the middle...Mid("Hello World", 4, 3) will return the text starting at character four, and ending three past it. ("o W").

    Believe me, I've looked, and tried writing my own, but I can't find functions like these for C++.....Any help?
    Jacob Sheehy

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    youll need to write what is called a parser. C/C++ doesnt have functions like those ... instead of strings, C++ has character arrays.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    19
    Yeah, I'm working with character arrays. I've tried writing my own functions/pasing routines, but MSDN wasn't much help. Suggestions?
    Jacob Sheehy

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    dont try to implement left right and mid, it may not be of much use. check out std::string and see what kind of functions it uses.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  3. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM
  4. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM
  5. Searching a linked list for char
    By spentdome in forum C Programming
    Replies: 3
    Last Post: 05-22-2002, 11:11 AM