大写单个字母而不是整个句子

Capitalize a single letter instead of the entire sentence

如何将字母“i”等大写?我试过变换,转换。现在,我认为使用 for 循环可能是最好的选择,但似乎无法弄清楚!

#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = "this is a test, this is also a test, this is yet another test";
int strLen = 0;
strLen = s.length();
for() //this is where I can't seem to figure it out
cout << s << endl;
return 0;
}

这是一个std::方式:

#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int main()
{
  string s = "this is a test, this is also a test, this is yet another test";
  char ch = std::toupper('i');
  std::replace(s.begin(), s.end(), 'i', ch);
  cout << s << endl;
  return 0;
}
// Assume that all dependencies have been included
void replaceAllLetters (string& s, char toReplace) {
    char new = std::toupper(toReplace);
    std::replace(s.begin, s.end, toReplace, new);
}
void replaceOneLetter (string& s, int index) {
  if (index < s.size()) s[index] = std::toupper(s[index]);
}