On this mastery I’ll show you what are strings and how to use them in C++.

String are things that are represented by a sequence of characters.

We will create a function that works as a palindrome and tells the user if the word he input is a palindrome or not. Do as follows:

  1. Create a main program and leave a space before it for the function
  2. Create a function of type string called palindrome
  3. Condition the user input with VARIABLE.rbegin and VARIABLE.rend. This iterators make the string return reversed to the beginning and end. This is the Palindrome “function”
  4. In main(), ask the user for the input and call for the function.

Your program should look something like this:

Now let’s test it:

Great! Now you know how to do a basic program using string. If you want to learn more about strings, go to this webpage:

http://www.cplusplus.com/reference/string/string/

CC BY 4.0 Mastery 25 by Omar Peza is licensed under a Creative Commons Attribution 4.0 International License.