Make 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.
Make 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.
Step by step
Solved in 2 steps with 3 images