toupper a string like cd123456?

Hello everyone, I was wondering how I could toupper my user input, which is in the format of cd123456. Basically, I just need to toupper the first two characters. Any help would be appreciated. Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <cctype>
#include <string>
#include <iostream>

int main()
{
    std::string input = "cd123456";
    for (unsigned i = 0; i < input.length(); ++i)
    {
        input[i] = toupper(input[i]);
    }
    
    std::cout << input << std::endl;
    return 0;
}
Thank you
 
for (char& c: input) c = toupper( c );
Topic archived. No new replies allowed.