I know what you're doing putting stars in the front and end of your functions, but as I tried to edit your code w/o *'s I was unsuccessful. All you had to do was copy and paste this into your main, but it takes 10 seconds to compile so your logic is getting into memory segmentation.
char word[LEN], *x, *y;
cout<<"Enter a word\n";
cin>>word;
char *result;
result = reverse_string(word);
cout<<result;
When I tried taking all the tokens out to have word passed in as a char, I'm not able to get the s1 to return the reverse value back.
You are clearly trying to use C-strings and the cat function because strcat put back together and then strcpy back into the argument c-string for the pass by reference to looping through the character array to make a backwards copy.
Here's a good example of deleting stuff w/o doing what you did above. Allowing less need for *s in main or in the function header calls.
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cctype>
using namespace std;
char removePunct(char[]);
int main()
{
int length;
string bob;
const int LEN = 64;
char word[LEN], x, y;
char *result;
cout<<"Enter a word\n";
cin>>word;
cout<<"You enter the word "<<word<<endl;
x=removePunct(word);
cout<<x;
return 0;
}
char removePunct(char word[])
{ // strtok example
char * pch;
//int length=strlen(word);
//printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (word," ,'\' '.-/];''[");
while (pch != NULL)
{
printf ("%s",pch);
pch = strtok (NULL, " ,'\' '.-/];''[");
word=pch;
}
}