reverse string c++

#include <iostream>
#include <string>

int main() {
    std::string input;

    // Step 1: Input a string
    std::cout << "Enter a string: ";
    std::getline(std::cin, input);

    // Step 2: Get the length of the string
    int length = input.length();

    // Step 3: Reverse the string
    for (int i = 0; i < length / 2; i++) {
        char temp = input[i];
        input[i] = input[length - i - 1];
        input[length - i - 1] = temp;
    }

    // Step 4: Output the reversed string
    std::cout << "Reversed string: " << input << std::endl;

    return 0;
}