Post: Hey I need Some HELP!!!! String Reversal
11-03-2010, 04:34 AM #1
Ritztro
I am a Game Developer
(adsbygoogle = window.adsbygoogle || []).push({}); Well I am trying to make a program that simply reverses the words entered. I want you guys to try it and tell me how ti works for you. I realize it stops workin half way lol and thats why i need help!!

Here is my code
    #include <iostream>
#include <string>
#include <conio.h>

using namespace std;

string reversal(string normal);


int main()
{
char tryagain;

do
{

string words_normal;

cout << "Please Enter some words:" << endl;
getline(cin, words_normal);

cout << "Your words reversed are:\n" << reversal(words_normal) << "\n\n" << endl;

cout << "Would you like to try again? (Y/N)" << endl;

while (tryagain != 'y' ||tryagain != 'Y' ||tryagain != 'n' ||tryagain != 'N'Winky Winky
{
cin >> tryagain;
}
}
while (tryagain == 'y' || tryagain == 'Y'Winky Winky;




return 0;
}

string reversal(string normal)
{

string reversed;

int a;
a = 0;
int i;
i = normal.length();

while (i>=0)
{

reversed[a] = normal[i];

a++;
i--;
}

return reversed;
}

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo