Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
524 B
8
Indexable
Never
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

string firstLetterToUppercase(string str) {
    int n = str.length();
    string result = "";
    for (int i = 0; i < n; i++) {
        if (i == 0 || str[i - 1] == ' ') {
            result += toupper(str[i]);
        }
        else {
            result += str[i];
        }
    }
    return result;
}

int main() {
    string str = "the quick brown fox jumps over the lazy dog";
    cout << firstLetterToUppercase(str) << endl;
    return 0;
}