sort+counting

This is a discussion on sort+counting within the C++ Programming forums, part of the General Programming Boards category; I don't see why that wouldn't work. The operator[] for strings returns a char just like it does for C-style ...

  1. #16
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    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.

Page 2 of 2 FirstFirst 12
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, 04:21 PM
  4. Can counting sort sort in descending order?
    By Nutshell in forum C Programming
    Replies: 3
    Last Post: 03-06-2003, 08:59 AM
  5. Shell Sort vs Heap Sort vs Quick Sort
    By mackol in forum C Programming
    Replies: 6
    Last Post: 11-22-2002, 07:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21