string strValue; // STL string. cin >> strValue; strValue.replace(strValue.begin(), strValue.end(), strValue.rbegin(), strValue.rend()); cout << strValue; Please learn STL in deep!