Question: Write a program to (1) Open an input file called in.txt for reading. The file in.txt will be located in the same directory from which

 Write a program to (1) Open an input file called "in.txt

Write a program to (1) Open an input file called "in.txt for reading. The file in.txt" will be located in the same directory from which the executable from your program will be run. The file "in.txt" will contain a list of integers, one integer per line. If the file "in.txt" does not apen successfully, print a message to the screen that the file in.txt does not exist, and exit the program. One way to check if the file was successfully opened is the following. If the statement fpi-fopen("ssn_in.txt"."r does not successfully open the file "in.txt" for reading then the FILE pointer fpi is equal to the macro NULL. That is if(fpiNULL)printf"The file in.txt did not successfully open") (2) Prompt the user of your program to enter an integer and read-in that integer from the keyboard. (3) Read the integers in the file "in.txt" and count the number of occurrences of the user's integer in the file Also, count the total number of integers in the file "in.txt while you are reading them. 4) Write out a message to the user containing the total number of occurrences of the user's integer in the file. Also, indicate to the user the total number of integers that were in the file "in.txt" In arder to test your program, use Microsaft text editor notepad exe to create a file called in.tt. Write some integer values inta the file and place the file in the folder containing your program executable file ".exe. Alternatively, if you are running xcode, create a sample file as we did in lecture and in Program 01 assignment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!