In: Computer Science
Write a complete C program that read the text below and save the text in a new file "second.txt" with the same text written in all uppercase.
"Beedle the Bard was an English wizard and author of wizarding fairytales. Beedle was born in Yorkshire, England. At some point in his life he wrote The Tales of Beedle the Bard . The only known image of Beedle is a woodcut that shows him with a "luxuriant" beard. Beedle wrote in ancient runes, which were later translated to English."
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
#include<stdlib.h>
#include <stdio.h>
#include <ctype.h> // used for toupper() function
int main(void)
{
// initialise variables
FILE *fp1;
FILE *fp2;
char ch;
fp1 = fopen("first.txt", "r");
fp2 = fopen("second.txt", "w+");
if(fp1==NULL || fp2==NULL)
{
// if error in opening a file
printf("Error in opening the file..!!");
exit(1);
}
while((ch = fgetc(fp1)) != EOF)
{
// read each character into ch and convert it to upper
using toupper() function in ctype.h
fputc(toupper(ch),fp2);
}
// CLOSE THE FILE POINTERS
fclose(fp1);
fclose(fp2);
return 0;
}
================
FILES"