Actually I was supposed to make a program to check for a entered string that weather its a palindrome or not, I wanted to make a function isPal() but it all jinxed and im all confused where to start and how to work on it, Actually I know that this program is not a difficult task if I'd have used string.h header file, but I want to take inputs character by character, and output as string ... I thought that it would be easy but it blew my head, but now I'm more stuck on it to only do it this way or find a solution of this way character-by-character.
It seems like my approach to this problem is kinda wrong, please correct me, or suggest me any idea soon ...
For the mean time, here's my incomplete effort:
Code:
#include<stdio.h>
#include<conio.h>
#define LIM 100
#define TRUE 1
void StRev(char array[],char array2[])
{
int c,x;
while(array[c]!='\0')
++c;
for(x=0;x<c;x++)
{
array2[x]=array[c-x];
}
}
int isPal(char arr2[])
{
char ch[LIM];
StRev(ch);
if(ch==arr2)
return 1;
else
return 0;
}
int main()
{
char In[LIM],out[LIM];
int count=0;
printf("Enter a String: ");
while( In[count] != '\x0D' );
{
In[count++]=getche();
}
if(isPal(In)==1)
printf("yes");
else
printf("No");
return 0;
}