First mistake you do something like:
char toBeRev;
scanf("%s", toBeRev);
so you try to fill toBeRev with the user input but %s take a char*
and not char
So you must have a buffer who can contain the input of the user.
char input[4096] = {0};
Then you say that you just need to print the string in a reverse order, so you don't need to change the value of your string, and you started with a recursive function (which is a good idea)
I have done something according to your exemple
void reverse(const char *str) //you don't need to modify your string
{
if (*str != '\0') //if the first character is not '\O'
reverse((str + 1)); // call again the function but with +1 in the pointer addr
printf("%c", *str); // then print the character
}
int main()
{
char input[4096] = {0};
printf("Enter a word please => ");
scanf("%s", input);
reverse(input);
printf("\n");
return (0);
}
so if the input is 'Hi', in the input you will have ['H']['I']['\0']
first call to reverse the string is ['H']['I']['\0']
second call the string will be ['I']['\0']
tird call ['\0']
and then you print the first character of the string so
IH