Hi!
Having some problems with functions in this one. As ypu can see I'm a tottal beginner. What I'm trying to do here is make a program checking if a word is a palindrome. Using 2 functions, one to check and one to reverse the user input string. My problem is simple, yet to hard for me. I can't seem to get to grips with the use of functions and how to call them.
The code I've written so far looks like this. Any help or pointers would be very appreciated.
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool palindromeCheck (char str1[], char str2[])
{
int i=0;
bool equal;
while (str1[i] == str2[i] && str1[i] != '\0' && str2[i] != '\0')
i++;
if (str1[i] == '\0' && str2[i] =='\0')
equal = true;
else
equal = false;
return equal;
}
char strReverse(char str1[], char str2[])
{
int i=0, j=0;
while(str1 != '\0')
j++;
j--;
while(i<=j)
{
char t = str1[i];
str1[i++] = str2[j];
str2[j--] = t;
}
return str2[100];
}
int main (void)
{
bool palindromeCheck (char str1[]);
char strReverse;
char str1[100];
char str2[100];
int i;
bool equal;
printf ("Enter word:");
scanf (" %s", str1);
strcpy (str1, str2);
printf ("\n\n");
if (equal=true)
{
printf ("Word is a plaindrome!\n");
}
else
{
printf ("Word is not a palindrome!\n");
}
system ("pause");
return 0;
}