Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the attached file below ( question.c ), there are coding questions on file operations which use the text file ( proj4.txt ) also provided

In the attached file below (question.c), there are coding questions on file operations which use the text file (proj4.txt) also provided below. Solve the questions:

question.c

#include  #include  #include  #define FILE_PATH "proj4.txt" #pragma warning(disable: 4996) // for Visual Studio Only FILE *fp; // Use this file pointer to open the file in readFile() and use this pointer through out this file. /* Problem 1: (10 points) Open the file proj4.txt. Use proper parameters to open the file for reading as well as writing. Display the size of the file. */ void readFile() { int fileSize = 0; // Enter your code here printf("The file size = %d bytes ", fileSize); } /* Problem 2: (15 points) Using file operations, calculate and display the number of words in the .txt file. */ void wordCount() { int words = 0; // Enter your code here printf("The word count = %d ", words); } /* Problem 3: (15 points) In findAndReplace(), ask the user for a word (find[]) to replace and the new word (replace[]) that will be inserted in its place. For simplicity, assume that both these words will be of same length. For example, user might enter find[]= "with" and replace[]= "into". So all instances of the word "with" should be replaced by "into". */ void findAndReplace() { char find[30], replace[30]; // Enter your code here } int main() { printf("CSE 220 p04q3: "); printf("Problem 1: "); readFile(); printf("Problem 2: "); wordCount(); printf("Problem 3: "); findAndReplace(); fclose(fp); //system("pause"); return 0; } 

proj4.txt

The different color components are surrounded with colored boxes. The BITMAPHEADER and BITMAPINFOHEADER bytes are surrounded by black boxes. The four pixels are surrounded by a box of the same color and the padding bytes are surrounded by purple boxes. Note that the pixels are stored in this order: blue, yellow (the bottom row of the image), red, green (the top row of the image). Note also that the RGB components of each pixel are stored in GBR order and the number of padding bytes on each row is 2. As each row has two pixels, which takes six bytes, and we need to add two padding bytes to make each row 8 bytes, in order to be multiple of 4. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions