Question

Part I) Write a program that copies one file to another, replacing all lowercase characters with...

Part I) Write a program that copies one file to another, replacing all lowercase characters with their uppercase equivalents. Part II) Write a program that merges lines alternately from two files and writes the results to a third file. If one file has less lines than the other, then the remaining lines from the larger file should be printed to the screen. Using C language

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For first program

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
      FILE *fp1, *fp2;
      char ch;
      fp1 = fopen("small.txt", "r");
      if (fp1 == NULL)
      {
            puts("File does not exist..");
            exit(1);
      }
      fp2 = fopen("capital.txt", "w");
      if (fp2 == NULL)
      {
            puts("File does not exist..");
            fclose(fp1);
            exit(1);
      }
      while((ch=fgetc(fp1))!=EOF)
      {
            ch = toupper(ch);
            fputc(ch,fp2);
      }
      printf("File successfully copied");
      return 0;
}

For Second program:-

#include <stdio.h>
#include <stdlib.h>
  
int main()
{
  
FILE *fp1 = fopen("first.txt", "r");
FILE *fp2 = fopen("second.txt", "r");
  
// Open file to store the result
FILE *fp3 = fopen("third.txt", "w");
char c;
  
if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
{
puts("Files missing");
exit(0);
}
  

while ((c = fgetc(fp1)) != EOF)
fputc(c, fp3);
  

while ((c = fgetc(fp2)) != EOF)
fputc(c, fp3);
  
fclose(fp1);
fclose(fp2);
fclose(fp3);
return 0;
}

I have attached the screenshots please check

Add a comment
Know the answer?
Add Answer to:
Part I) Write a program that copies one file to another, replacing all lowercase characters with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a c program that takes in a text file and writes lines with only lowercase...

    Write a c program that takes in a text file and writes lines with only lowercase letters to another text file which is disclosed from the command line. If no text file to output to is disclosed in the command line, the lines with only lowercase letters should be written into a text file called "all_lower.txt"

  • C++ please Write a program that reads the following sentences from a file: I am Sam...

    C++ please Write a program that reads the following sentences from a file: I am Sam Sam I am That Sam I am That Sam I am I do not like that Sam I am Do you like green eggs and ham I do not like them But I do like spam! You will first have to create the text file containing the input, separate from your program. Your program should produce two output files: (i) (ii) one with the...

  • in c++ language, using quincy compiler Write a program that will read in 12 characters from...

    in c++ language, using quincy compiler Write a program that will read in 12 characters from the keyboard between a – z in lowercase. These letters will be inserted into a queue (imported from the Queue.h header file). When the 12th character has been entered, the queue will serve the characters one at a time to a character variable, which will push the values, one at a time, into a stack (using code imported from the Stack.h header file) and...

  • Write a C program which is called ‘multiple_copy’. This program copies one source file to two...

    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...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • Write a program that reads in a text file, infile.txt, and prints out all the lines...

    Write a program that reads in a text file, infile.txt, and prints out all the lines in the file to the screen until it encounters a line with fewer than 4 characters. Once it finds a short line (one with fewer than 4 characters), the program stops. For your testing you should create a file named infile.txt. Only upload your Python program, I will create my own infile.txt. Please use a while-loop BUT do not use break, Exit or Quit...

  • Write a program that will take input from a file of numbers of type double and...

    Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...

  • General Requirements . . . Write a program that reads letters from a file called "letters.txt"....

    General Requirements . . . Write a program that reads letters from a file called "letters.txt". Your program will open the letters.txt file read in one character at a time For this assignment the test file will contain at least 30 letters, uppercase OR lowercase In your program you will change each letter (solution) to uppercase Use the function toupper in #include <ctype.h> You create a numerical version of the uppercase letter from the file . o Use int numberSolution...

  • Write a C++ program that reads text from a file and encrypts the file by adding...

    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 program that reads a series of words (one word per line) from a file...

    Write a program that reads a series of words (one word per line) from a file named data.txt. Each word in the file should have each of its characters shifted by 1 character value in the ASCII table (incremented) and then that new word with its characters shifted should be printed to a new file named result.txt. Each word from data.txt should be reprinted with its new encoding in result.txt. Your program should not have any knowledge of how many...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT