Thread: simple AnsiString question

  1. #1
    Registered User
    Join Date
    Jan 2002

    simple AnsiString question

    is there a quick way of taking out the first few letters of an ansistring? i.e.
    String astring = abcdef;
    temp = astring[1 to 3];

    temp stores only abc

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    string substr (size_type pos, size_type n);
    Returns a substring of the current string, starting at position pos and of length n:

    string str18 = "abcdefghi"
    string str19 = str18.substr (6,2);
    cout << str19 << endl; // "gh"
    Might want to bookmark this page.. it's highly useful for documentation with the most popular STL classes.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  2. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  3. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM