I'm trying to get my code to except input and then reverse and print it without any extra lines. I've taken all the \n out to see if that helps but I always get a new line before my print. I'm guessing that it's printing the null character at the end of the users input but I don't know how to get rid of it.
This is what I have so far
#include <stdio.h>
#include <string.h>
void revStr(char str[]);
int main(void)
{
char str[50];
fgets(str, 50, stdin);
if ((strcmp(str, "quit\n") == 0) || (strcmp(str, "q\n")==0) || (strcmp(str, "Quit\n")== 0)){
printf("\n");
return 0;
}
else{
revStr(str);
return main();
}
}
void revStr(char str[])
{
int arrSz = strlen(str);
int i;
for(i = arrSz-1; i >= 0; i--){
if(str[i] != '\0')
printf("%c",str[i]);
}
}