I've got some of my project finished. This is supposed to 1) check to see if each word in the input file is a palindrome using stacks
2) If the word is a palindrome, write the word to a separate output filr.
3) Count the number of words read and the number of words which are found to be palindromes.
Here is my main.c file
#include<stdio.h>
#include "Palindrome.h"
#define SIZE 300
int main(void)
{
char txt[500];
readFile(txt);
writeFile(txt);
checkPalindrome();
return 0;
}
This is my function definition.c file. Now should I use stacks to check for palindromes in the current functions? or should I make a whole new function for that?
#include<stdio.h>
#include "Palindrome.h"
#define SIZE 300
void readFile(char txt[])
{
char txtname[100];
FILE *rfPtr;
printf("Please enter a file to read for palindromes.\n");
scanf("%s",txtname);
rfPtr=fopen(txtname,"r");
if (rfPtr==NULL)
{
printf("File cannot be opened!\n");
}
else
{
while(!feof(rfPtr))
{
fscanf(rfPtr,"%s",txt);
printf("%s ",txt);
}
}
fclose(rfPtr);
return;
}
void writeFile(char txt[])
{
FILE *cfPtr;
cfPtr=fopen("J:\\Palindrome\\Debug\\output.txt","w");
if(cfPtr==NULL)
{
printf("File cannot be opened!\n");
}
else
{
fprintf(cfPtr,"%s ",txt);
}
fclose(cfPtr);
return;
}
and here is my palindrome.h file
#include <stdio.h>
void readFile(char txt[]);
void writeFile(char txt[]);
//void checkPalindrome();