Thread: sort+counting

  1. #16
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    I don't see why that wouldn't work. The operator[] for strings returns a char just like it does for C-style strings.

  2. #17
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    If you must use STL strings, but for some reason you want to access the Cstyle string the STL string is based on (STL string class has a char * as a private/protected data member to hold the C style string), you can use the c_str() method to get the underlying C style string. However, as jlou posted, the [] works for STL strings just as it does for Cstyle strings so there really isn't any need for pulling out the Cstyle string in this instance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Straight Insertion Sort function problem
    By StaticKyle in forum C++ Programming
    Replies: 6
    Last Post: 05-12-2008, 04:03 AM
  2. threaded merge sort
    By AusTex in forum Linux Programming
    Replies: 4
    Last Post: 05-04-2005, 04:03 AM
  3. Sorting
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 11-10-2003, 05:21 PM
  4. Can counting sort sort in descending order?
    By Nutshell in forum C Programming
    Replies: 3
    Last Post: 03-06-2003, 09:59 AM
  5. Shell Sort vs Heap Sort vs Quick Sort
    By mackol in forum C Programming
    Replies: 6
    Last Post: 11-22-2002, 08:05 PM