I can't get my for loop to reverse the array pal into rpal (reverse palindrome). I've tried putting in a temp. I've tried changing the order. Nothing I do works. I just got it to the point now where it'll print out the string properly I just need it to check whether or not the string is a palindrome or not.Code:#include <stdio.h>
#include <string.h>
#define MAX 50
#define Null '\0'
int getStringF(char [],int, FILE *);
main()
{
int b,e,numChar,leng,eof;
float comp;
char pal[MAX+1], rpal[MAX+1],temp;
FILE *payInFile, *payOutFile;
payInFile = fopen("sample.txt","r");
payOutFile = fopen("sampout.txt","w");
fprintf(payOutFile,"Palindrome Program Fall 2011 by Bradley Lantz\n");
fprintf(payOutFile,"Project #6 Due 12/9/11\n\n");
fprintf(payOutFile,"Palindrome? Input String\n");
numChar = getStringF(pal,MAX,payInFile); //printf here prints 1st string
leng = numChar;
for(b=0;b<MAX;b++)
rpal[b]=0;
while (numChar!=0)
{
temp=0;
e = leng;
for (b=0;b!=Null; b++) //b<numChar && e!=0 (condition)
{
pal[b] = rpal[leng]; //pal[e-1]
leng--;
}
printf("%s %s", pal, rpal);
comp = strcmp(pal,rpal);
if (comp==0)
fprintf(payOutFile,"YES %s*\n",pal);
else
fprintf(payOutFile,"NO %s*\n",pal);
numChar = getStringF(pal,MAX,payInFile); //printf here prints 1st string
leng = numChar;
}
fprintf(payOutFile,"\nEnd of Program, Normal Termination");
system("pause");
}
int getStringF(char s1[],int max, FILE *in)
{
char c;
int p=0;
c=getc(in);
while ((c!=EOF) && (c!='\n') && (p < max))
{
s1[p]=c;
p++;
c=getc(in);
}
s1[p] = '\0';
return p;
}