Starting/ending for transform()

Hi, so obviously I'm a newbie.
I have no idea how to change the ending position of the transform function.
So...

 
  transform(myStr.begin(), * , myStr.begin(), toupper);


what would I need to put at the * if I wanted to uppercase only the first 3 letters of the string?

Thanks!
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s="abcde";
	string out;
	std::transform(
	   s.begin(),
	   s.begin()+3,
	   back_inserter(out),
	   (int (*)(int))std::toupper  // specific overload requested
	);
	cout<<out;
	return 0;
}


this would convert the first three but only three. and get rid of the rest.
you can probably replace the first three letter of the string with the uppered string, i guess.
or you can use substring .
goodluck
Topic archived. No new replies allowed.