The task is to read string and swap the first char with the last. Here is my code: I don`t understand why is the imput the same as the output. Thanks very much for your help.

```
#include <iostream>
#include <string>

using namespace std;

int main()
{
    cout << "Enter string: " << endl;
    string str;
    cin >> str;

    char first = str[0];
    int lastChar = str.length() -1;
    char last = str[lastChar];
    char temp;

    temp = first;
    first = last;
    last = temp;

    cout << last << endl;

    return 0;
}

```