Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will implement a tweet maker. As you probably know, tweets are limited to 2 8 0 characters. This program will take

In this assignment, you will implement a tweet maker. As you probably know, tweets are limited
to 280 characters. This program will take an existing text file and reduce its size in an attempt to
fit it within a standard tweets size. Specifically, the program will input two file names, an input
file and an output file, and two characters, all from the user. The program will open both files and
iterate through the input file character-by-character (using getc), copying each character to the
output file (using putc) unless the character is one of the following:
1. a digit or a punctuation mark other than period, exclamation mark and question mark
2. a letter and matches the preceding letter (case insensitive), for instance if you have oo it
will not output the second o and if you have Cc it will not output the second c
3. matches either of the two input characters from the user (case sensitive), for instance if the
user enters a and b then any a and b are not output, but A or B would be output
To input a character, use %c for the specification string in scanf instead of %c. If you
want to input both chars in one scanf, use %c %c.
In addition to outputting (or not) the input files characters to the output file, count the number of
characters from the input file (as you input them) and the number of characters sent to the output
file. After exiting the loop controlling the character-by-character input/output, close both files,
compute the fraction of size that the output file is of the input file (see below) and then output a
report using printf statements detailing the following:
name and size (number of characters) of input file
name and size of output file
percent difference (output files size / input files size *100) as
a floating-point value with 2 decimal points of accuracy
if the output file has more than 280 characters, a message that the file (by name) cannot be
tweeted
The output should be formatted so that the file names, sizes and the percent difference line up.
On the page with this assignment are three text files. Run your program on the first file,
p1in1.txt using the characters A and e as the user input (the characters to not output). You
should receive output like the following (below you see the report generated and on the next page
the output text file).
Console input (first 3 lines) & output:
Enter the input file name: p1in1.txt
Enter the output file name: p1out1.txt
Enter two characters to skip: A e
Summary of operation:
Size of input file p1in1.txt 456
Size of output file p1out1.txt 370
Reduction in size of output 81.14%
Error, p1out1.txt exceeds the standard tweet size!
Notice the file names in the output and the numbers line up.
Output file:
bduction is dfind as infrnc to th bst xplanation
a task of gnrating an xplanation to acount for th
aparanc of a givn st of findings or data . bduction
has prviously bn aplid to a wid rang of intrprtation
problms including spch rcognition diagnosis
mdical tst intrprtation story
undrstanding natural languag undrstanding
thory formation and lgal rasoning .
Debug your program if you receive different output. Note: if your output count is off by 1-2, it is
acceptable.
Once the program is running correctly, run the program on p1in2.txt as the input file with
characters A and e for the user input, and p1in3.txt as the input file with the characters m and
M for the user input. Collect the output from these two runs, paste them at the bottom of your .c
file in comments and submit the single file. You should have 5 things in this file:
1. your .c source code
2. the console output when run on p1in2.txt
3. the text file created when run on p1in2.txt
4. the console output when run on p1in3.txt
5. the text file created when run on p1in3.txt

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

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions