June 20, 2022 |18.4K Views

    C++ Program to Reverse a String

    Description
    Discussion

    In this video, we will see C++ Program to Reverse a string. As we know a string is a collection of characters and a string class is part of the C++ library that supports a lot much functionality over C-style strings.

    Reversing a string is nothing but simply replacing the last element of a string in the first position of the string.

    Examples:
    1) Input string: abcdef
    Output string :fedcba

    2) Input string: GEEKSFORGEEKS'
    Output string: ‘SKEEGROFSKEEG

    Here in this, we see three different methods for a reverse a string in C++.
    1) By User-defined functions
    2) Using an In-built function
    3) Using temporary string

    Link:
    C++ Program to reverse a string: https://www.geeksforgeeks.org/reverse-a-string-in-c-cpp-different-methods/ 
    C++ Program to reverse a string using iterative & recursive approach: https://www.geeksforgeeks.org/program-reverse-string-iterative-recursive/