Thank you for solution

Sounds like a reasonable assignment, but what specifically are you having trouble with? We aren't a homework service, but will help you if you get stuck.

This site offers a basic tutorial section:
http://www.cplusplus.com/doc/tutorial/
http://www.cplusplus.com/doc/tutorial/functions/

There are also other tutorials on strings:
https://www.learncpp.com/cpp-tutorial/4-4b-an-introduction-to-stdstring/
string toLowerCase(string &s) //&s is correct, but teacher may want without & which is fine
//without makes a pointless copy. with, the function can be void, there isnt any need to return s, but assignments ask for dumb things at times.
{
std::transform(s.begin(), s.end(),s.begin(), ::tolower); //or very close to this, been a while
return s;
}

As said, we prefer not to do homework for you, but I will give you a one liner like this as everyone has days when they just need an example to get kick started.
Last edited on
Here's another starter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>

void char_to_lower_case(char&);
std::string string_to_lower_case(const std::string);

int main()
{
    char test1{'a'};
    char_to_lower_case(test1);
    std::cout << test1 << '\n';
    
    std::string test2{"A2BRaCADABRA1"};
    std::cout << string_to_lower_case(test2) << '\n';
    
    return 0;
}

void char_to_lower_case(char& ch)
{
    if(ch < 'A' or ch > 'Z')
        return;
    else
        ch = ch - 'A' + 'a';
    
    return;
}

std::string string_to_lower_case(const std::string str)
{
    // SHOULDN'T BE TOO HARD TO FILL THIS OUT;
}


a
a2bracadabra1
Program ended with exit code: 0
Topic archived. No new replies allowed.