I have an argv c program, and it reverses the word, and sees if it's a palindrome. I just want to clean up the output and have it print the original input instead of the reversed one, but since it's argv, I can't seem to figure out how to do it.
int main(int argc, char* argv[])
{
char *string = (char*)malloc(1000);
string[0] = '\0';
for(i = 1; i < argc; i++)
strcat(string, argv[i]);
for(j = 0; string[ j ]; j++)
string[j] = tolower(string[ j ]);
reverse(string);
printf("Reverse of entered word is \"%s\".\n", string);
result = is_palindrome(string);
if ( result == 1)
printf("\"%s\" is a palindrome.\n", string);
else
printf("\"%s\" is not a palindrome.\n", string);
system("pause");
}
I left out the rest of the functions, but you can see in the main the printf showing whether it is or isn't a palindrome. Not sure how to get that to equal the original input, and knowing the amount of arguments. Currently it prints the reversed string, when I think it would look better printing the original. I think I'm making this too hard but i'm not sure.