Write a program to read the file "input.txt", which contains one student's name for one line, such as John Karl Tom You need to output them together with the line number of each name to the file “output.txt", such as 1, John 2, Karl 3, Tom At last, you also need to output the total number of students, such as printing out The total number of students is xxx. (xxx is 3 with the above case) Please include appropriate checks on the opening of the file.
Write a program to read the file "input.txt", which contains one student's name for one line, such as John Karl Tom You need to output them together with the line number of each name to the file “output.txt", such as 1, John 2, Karl 3, Tom At last, you also need to output the total number of students, such as printing out The total number of students is xxx. (xxx is 3 with the above case) Please include appropriate checks on the opening of the file.
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
Related questions
Question
Please write the code in C program:
Input file:
John
Karl
Tom
Jerry
Ryan
Joshua
Frank
![Write a program to read the file "input.txt", which contains one student's name for one line, such as
John
Karl
Tom
You need to output them together with the line number of each name to the file "output.txt", such as
1, John
2, Karl
3, Тom
At last, you also need to output the total number of students, such as printing out
The total number of students is xxx. (xxx is 3 with the above case)
Please include appropriate checks on the opening of the file.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb719cd5a-985e-4dc1-9bb3-1a331a74fcd3%2F9445b208-37e1-4c3c-b569-684c689b5035%2Fon3ycyc_processed.png&w=3840&q=75)
Transcribed Image Text:Write a program to read the file "input.txt", which contains one student's name for one line, such as
John
Karl
Tom
You need to output them together with the line number of each name to the file "output.txt", such as
1, John
2, Karl
3, Тom
At last, you also need to output the total number of students, such as printing out
The total number of students is xxx. (xxx is 3 with the above case)
Please include appropriate checks on the opening of the file.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning