I would appreciate it if you’ s could help me out on the following code. I have a piece of code, which finds if a palindrome exists on the word entered (palindrome is a string that is spelt the same way forwards as backwards) which works perfectly. However I have a file to be opened in command line arguments and assuming that the file in this case to be opened is “palindrome.txt” and containing a palindrome of text within this file (example = i saw radar was i), I have to print to the screen whether this file contains a palindrome or not after it is opened through command line argument (i.e argv, argc). Combining the 2 pieces of code below or thereabouts I think it will allow me to do this, but I am unsure on how to write it. The output might look as follows “palindrome.txt contains 5 words (i saw radar was i) and contains a palindrome”. It would be of great help if the code below were rewritten for me in order to achieve this. Thanks a lot !

//code to find out whether a word is a palindrome
int main(void)
{
char string[50];
int tag, count, back, flag=1;

puts("Enter a word : ");
for(count = 0; (string[count] = getchar()) != '\n'; ++count);
tag = count - 1;

for((count = 0, back = tag); count <= tag/2; (++count, --back))
{
if(string[count] != string[back])
{
flag = 0;
break;
}
}

for(count = 0; count <= tag; ++count)
putchar(string[count]);

if(flag == 1)
puts(" is a palindrome\n");
else
puts(" is not a palindrome\n");



getch();
}



//code to find out whether file contains palindrome text when opened - unfinsihed
int main (int argc, char *argv[])
{
FILE *FilePtr; /* Pointers to the File */
char LineRead[100];
int Count=0, i;


if (argc==2)
{/* Open the file palindrome.txt for Reading */
if( (FilePtr=fopen("palindrome.txt", "r")) == NULL)
printf("ERROR OPENING FILE\n");
else
{ /* File Opened so...*/
/* While LineRead != End Of File */
while( (fgets(LineRead, 100, FilePtr) ) != NULL) /* Read Line from palindrome.txt */
{
/* Ensure i is zero */
i=0;
/* Add one to Count for next line - if its not '\n' */
if(strcmp(LineRead, "\n") != 0)
Count++;
/* Count the number of spaces in the Line Read */
while(LineRead[i] != '\0')
{
if(LineRead[i++]==' ')
Count++;
}
}
}

/* Display the number of words in the file */
printf("%d words in %s ", Count, argv[1]);
/* Close the Files */
fclose(FilePtr);
}