Write a C program that gets a source file name from a user. If the file does not exist, it will generate a proper error and exits. If the file exists, it also gets the name of two more files from the user, say destination1 and destination2. These files don’t need to exist as they are files that need to be written to. If the files cannot be opened for writing, a proper error will be generated. The program then reads the source file line by line. It will copy every line that has a digit in it to destination 2 and lines that have no digit in them to destination 1. Feel free to use ctype’s isdigit() function to identify digit characters.   Example: If source file is: Hi My name is Veria Hello My name is John. How can I help you? I have a problem with my giga bit internet. The speed should be around 1000 but it’s just 200 Sure! I can help with that. Can I have your number in case we get disconnected? Sure! My number’s 647-123-1234   First file (destination 1) should be Hi My name is Veria Hello My name is John. How can I help you? Sure! I can help with that. Can I have your number in case we get disconnected?   Second file (destination2) should be I have a problem with my giga bit internet. The speed should be around 1000 but it’s just 200 Sure! My number’s 647-123-1234   The program then displays a report mentioning how many lines were copied into each destination file.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a C program that gets a source file name from a user. If the file does not exist, it will generate a proper error and exits.
If the file exists, it also gets the name of two more files from the user, say destination1 and destination2. These files don’t need to exist as they are files that need to be written to.

If the files cannot be opened for writing, a proper error will be generated.

The program then reads the source file line by line. It will copy every line that has a digit in it to destination 2 and lines that have no digit in them to destination 1. Feel free to use ctype’s isdigit() function to identify digit characters.

 

Example:

If source file is:
Hi My name is Veria
Hello My name is John. How can I help you?
I have a problem with my giga bit internet. The speed should be around 1000 but it’s just 200

Sure! I can help with that.

Can I have your number in case we get disconnected?

Sure! My number’s 647-123-1234

 

First file (destination 1) should be

Hi My name is Veria

Hello My name is John. How can I help you?
Sure! I can help with that.

Can I have your number in case we get disconnected?

 

Second file (destination2) should be

I have a problem with my giga bit internet. The speed should be around 1000 but it’s just 200

Sure! My number’s 647-123-1234

 

The program then displays a report mentioning how many lines were copied into each destination file.

 

Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY