Originally Posted by
joshdick
Sorry I missed that. In that case, I suggest just implementing your own versions of those functions.
For the function to reverse a string, your logic is wrong. You need to swap the characters. First, the first and last characters; then, the second and second to last characters; etc.
Here's the code but its still not working ...
Code:
#include<stdio.h>
#include<conio.h>
#define LIM 100
#define TRUE 1
void swapCh(char var1,char var2)
{
char temp;
temp=var1;
var1=var2;
var2=temp;
}
void StRev(char array[],char array2[])
{
char ch;
int count=0;
int x,y;
while(array[count] != '\0')
++count;
for(x=count,y=0;x<count;x--,y++)
swapCh(array[y],array2[x]);
}
int isPal(char arr2[])
{
char ch[LIM];
StRev(arr2,ch);
if(ch==arr2)
return 1;
else
return 0;
}
int main()
{
char In[LIM],out[LIM];
int count=0;
clrscr();
printf("Enter a String: ");
while( In[count++] != 13 )
{
In[count]=getche();
}
StRev(In,out);
printf("\n%s",out);
if(isPal(In)==1)
printf("\nyes");
else
printf("\nNo");
return 0;
}