string

I want to create 2 functions to (1) convert a passed string into proper case (capitalize the first alpha character of a string and every alpha character that follows a non-alpha character); (2) sort the array of names (after it has been converted to proper case).
I tried these two:
console.writeline (lower.toUpper());
void bubblesort (string array[],int length);

but I don't know if they are good.somebody has an idea please?
I would suggest trying it. :)

What is your criteria? I can do many things by throwing pennies off a roof, but are they in line with what is trying to be accomplished?
1) If you don't mind C++11:
1
2
3
4
5
6
7
8
9
10
#include <string>
#include <algorithm>
#include <cctype>

void capitalize(std::string x)
{
    std::transform(x.begin(), x.end(), x.begin(), (int (*)(int))std::tolower);
    auto pos = std::find_if(x.begin(), x.end(), (int (*)(int))std::isalpha);
    *pos = toupper(*pos);
}

If you do however there is some pointers for you:
First you should iterate over all characters in string (using range-based for on normal for loop) and apply std::tolower() to all of them.
Second you should sind first alpabetical character in string and apply toupper() to it.

2) There is std::sort() function...
Topic archived. No new replies allowed.