MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / main

Function main

Exercises/Modules/Chapter 08/Soln8_02.cpp:11–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9std::string reverse(std::string str);
10
11int main()
12{
13 std::string sentence;
14 std::cout << "Enter a sequence of characters, then press 'Enter': " << std::endl;
15 getline(std::cin, sentence);
16
17 std::cout << "\nYour sequence in reverse order is:\n";
18 std::cout << reverse(sentence) << std::endl;
19
20 std::cout << "\nHere is a demonstration of reverse() working with a C-style string:\n";
21
22 char stuff[] {"abcdefg"}; // C-style string
23 std::cout << "\nThe original string is: \"" << stuff << "\""
24 << "\nReversed it becomes: \"" << reverse(stuff) << "\"" << std::endl;
25}
26
27// Reverse a string in place
28// The code here is working with a copy of the argument

Callers

nothing calls this directly

Calls 1

reverseFunction · 0.70

Tested by

no test coverage detected