my program is running, but logically wrong..
Assume that there are two text files. write a program that will determine whether these two text files are identical or not..
it doesn't important if the program print the content of each program.. the important is it compare the content of the first text file to another text file... and print only whether they're equal or not
help me please and give me some advice....
heres my program..
Code:
#include<stdio.h>
void main(void)
{
FILE *inputf1;
FILE *inputf2;
int x,y;
char filename1[40];
char filename2[40];
printf("Input name of the text file:\n");
scanf("%s",&filename1);
printf("Input another text filename:\n");
scanf("%s",&filename2);
if(filename1!=filename2)
printf("they're not equal\n");
if((inputf1 = fopen(filename1, "r")) == NULL)
if((inputf2 = fopen(filename2, "r")) == NULL)
{
printf("ERROR: %s cannot be opened:\n",filename1);
printf("ERROR: %s cannot be opened too:\n",filename2);
getch();
exit(1);
}
while((x = fgetc(inputf1)) !=EOF)
while((y = fgetc(inputf2)) !=EOF)
printf("%c",x);
printf("%c",y);
fclose(inputf1);
fclose(inputf2);
}
so many Thanks for all of your help...