Can anyone please fix my program. When I run it and for example : I type --> hello world , when it does the reverse it shows dello worl4. Please fix my problem. I would appreciate it very much. The reverse should say dlrow olleh
-----------------------------------------------------------
#include <iostream>
#include <string.h>
using namespace std ;
void strReverse ( char *pString ) ;
int main ()
{
charch[20] ;
cout<< "Please enter the string you want to reverse: " ;
cin.getline ( ch, 20 ) ;
strReverse( ch ) ;
cout<< "Your string reversed is: "
<< ch
<< '\n' ;
return 0 ;
}
//
//********************************************************************
**********
//****
// Routine:strReverse ()
// Programmeraniel Mulcahy
// Purpose:This routine reverses a string
// ParametersString - type char * : The string to be left trimmed
in
//place.
// Returns:Nothing.
//
//********************************************************************
**********
void strReverse (char *pString){
int i,k;
char temp;
for(i=0,k=strlen(pString)-1;i>=k;i++,k--)
temp = pString;
pString = pString[k];
pString[k] = temp;
}
-----------------------------------------------------------
#include <iostream>
#include <string.h>
using namespace std ;
void strReverse ( char *pString ) ;
int main ()
{
charch[20] ;
cout<< "Please enter the string you want to reverse: " ;
cin.getline ( ch, 20 ) ;
strReverse( ch ) ;
cout<< "Your string reversed is: "
<< ch
<< '\n' ;
return 0 ;
}
//
//********************************************************************
**********
//****
// Routine:strReverse ()
// Programmeraniel Mulcahy
// Purpose:This routine reverses a string
// ParametersString - type char * : The string to be left trimmed
in
//place.
// Returns:Nothing.
//
//********************************************************************
**********
void strReverse (char *pString){
int i,k;
char temp;
for(i=0,k=strlen(pString)-1;i>=k;i++,k--)
temp = pString;
pString = pString[k];
pString[k] = temp;
}