#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int areTheyEqual(FILE *fp1, FILE *fp2)
{
//getting characters in two files in two char variables a and
b
char a=getc(fp1);
char b=getc(fp2);
//running loop until atleast one of them reaches end of file
while(a!=EOF && b!=EOF)
{
if(a!=b) return 0;//if two characters at any time are not equal
returning 0
//again giving new values to a and b
a=getc(fp1);
b=getc(fp2);
}
//if one variable reaches end of line and other doesnot then the
two files are not equal
if(a!=EOF &&b!=EOF) return 0;
//if it came here then the two files are equal so returning 1
return 1;
}
int main() {
//we shall open files in read only format
FILE *fp1 = fopen("first.txt", "r");
FILE *fp2 = fopen("second.txt", "r");
//checking if any pointers are NULL
if (fp1 == NULL || fp2 == NULL)
{
printf("files did not opened");
exit(0);
}
//if the function returns 1 then they are equal else they are not
equal
if(areTheyEqual(fp1,fp2)) printf("they are equal\n");
else printf("they are not equal\n");
//closing the two files
fclose(fp1);
fclose(fp2);
return 0;
}




if you are satisfied please
upvote or if you have any doubts post them in comment section happy
learning
Write a c program CH-12 TEXT FILES EXERCISE 12-12 Write a program to read two files of the same length, and determine if they are equal. For example: if one of the file has the content 123 abc 45...
Write c program. Do part 4 and 5
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file...
Write a c program.
CH-12 has arbitrary number of lines and one num. txt EXERCISE 12-11 te a program to create a new file numnew. txt that will he ine. A text file will have number in reverse order of the file num.txt For example: M the num.txt file is 7632 582 13101 then the numnew. txt file will be 1367 285 10131
CH-12 has arbitrary number of lines and one num. txt EXERCISE 12-11 te a program to create...
C++.Write a program that opens two text files and reads their contents into two separate queues. The program should then determine whether the files are identical by comparing the characters in the queues. When two nonidentical characters are encountered, the program should display a message indicating that the files are not the same. If both queues contain the same set of characters, a message should be displayed indicating that the files are identical. Sample Run Suppose we have two files...
IN PYTHON Write a program that reads two text files, take one sentence from each text file and print them one after another. Example: If line1 is from text1.txt and line2 is from text2.txt, then print line1 line2 Repeat this for all the lines of the two files
Write a python program that prompts the user for the names of two text files and compare the contents of the two files to see if they are the same. If they are, the scripts should simply output “Yes”. If they are not, the program should output “No”, followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file. The loop should break as soon as a...
In C Programming Language, write a simple program to read one text file and print to screen all its text. Make use of the stderr and exit program statements should there not be only one text file identified on the command line. If successful then before fclose of the text file, use the fputs program statement to write a line "72 degrees Sunny light wind. Nice!\n". print the return code of fputs (should be zero). close and exit. Test program...
4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...
Write a C program which is called ‘multiple_copy’. This program copies one source file to two destination files as follows: $./multiple_copy....... source_file....... destination_file1......... destination_file2 multiple_copy program copies the contents of source file (i.e., source_file) to any named two destination files in the command line. The number of arguments should be 4 including multiple_copy. If the number of arguments is not 4, the program should display error message saying: “Usage: multiple_copy source_file destination_file1 destination_file2”. When the source_file does not exist, the...
Write a C++ program that combines the content of the two inputs files, ip1.txt and ip2.txt and writes the combined data into an output file name op.txt. Each line of op.txt contains the student name from ip1.txt and GPA from ip2.txt as follow: LastName, FirstName / GPA Note: assume the contain in ip1.txt: FirstName LastName The program must read ip1.txt and ip2.txt until it reach the end of file.