make part of a string upper case

I want a specific part of my string to be converted to upper case, but all I can find for this is std::transform and I can only seem to convert the entire string. All examples I've found use string.begin() and string.end() as the arguments and everything else I've tried hasn't worked. This is the only thing I've used that hasn't given a compilation error:

 
std::transform(thisLine.begin(), thisLine.end(), thisLine.begin(), toupper);


I'm also confused as to what the 'first2' parameter is. Any help would be appreciated, thanks.
Last edited on
> I'm also confused as to what the 'first2' parameter is

thisLine.begin() and thisLine.end() are iterators.
http://www.mochima.com/tutorials/STL.html#Containers_and_Iterators

1
2
3
4
5
6
7
std::string thisLine = "abcdefghijkl" ;

// convert characters in positions 5,6,7,8 to upper case
std::transform( thisLine.begin()+4, thisLine.begin()+9, thisLine.begin()+4,
                  [] ( char c ) { return std::toupper(c) ; } ) ;

std::cout << thisLine << '\n' ;

Ah, I understand. Thanks for your help.
Topic archived. No new replies allowed.