write a program that gets an input tabular format

Description

You can use this video as a reference to complete the assignment.

Don't use plagiarized sources. Get Your Custom Assignment on
write a program that gets an input tabular format
From as Little as $13/Page

Unformatted Attachment Preview

COP-4338 System Programming
Programming Assignment 3:
C I/O
FIU Knight Foundation School of Comp. & Info Sciences
In this assignment, you will write a program that gets an input tabular format (txt1
or csv2 ) and an output tabular format (txt or csv) as command-line arguments, receives
multiple lines from the standard input stream in the given input format, and fnally prints
out the lines after converting them to the given output format.
1
Program Command Line Arguments
The program must support the following command-line arguments:
• -i fmt: specifies the input format where fmt is a placeholder for one of the two supported
formats: csv or txt. Default input format is txt.
• -o fmt: specifies the output format where fmt is a placeholder for one of the two
supported formats: csv or txt. Default output format is csv.
• -e: makes the program to convert the values of cells containing double values to their
equivalent normalized scientific notation with 3 digits of precision after the decimal
point.
• -x: makes the program to convert the values of cells containing integer values to
their equivalent hexadecimal values.
• -s: makes the program to truncate the values of cells containing non-numerical strings
to prefixes of length 5. If the length of a cell value is less than 5, the program does not
change the cell value.
• -c: makes the program to remove leading and trailing white-spaces from each cell of
input data.
1
a.k.a. tab-delimited format which is used for storing tabular data. In this format, cells of the same row
are separated by tab and two consequent rows are separated by a new line.
2
a.k.a. comma-separated values format which is used for storing tabular data. In this format, cells of the
same row are separated by comma and two consequent rows are separated by a new line.
1
2
Input/Output of Your Program
Your program must accept a sequence of lines followed by an EOF character from standard
input stream. Here is an example of program input:
12
-12.3
Hello World!
Sentence
23.
-23 ctrl + D
The output is given under diferent combinations of command-line arguments:
CLAs
Expected Output
12,-12.3,Hello World!
Sentence
„,
./convert
,23.,-23
c,-1.230e+01,Hello
Sente„ ,
./convert -exsc
,2.300e+01,fffe9
12,-12.3,Hello World!
Sentence
„,
./convert -i txt -o csv
,23.,-23
c,-1.230e+01,Hello
./convert -i txt -o csv -xces Sente„ ,
,2.300e+01,fffe9
12 -12.3 Hello World!
Sentence
./convert -i csv -o csv
23. -23
12 -12.3 Hello World!
Sentence
./convert -i csv -o txt
23. -23
3
Submissions
You need to submit a .zip fle compressing the followings:
• all .c and .h fles
• makefle which organizes the compilation process of your program. Use the word
“convert” to name the executable of your program.
2
#include
#include
#include
#include
#define error(m, c) do{fprintf(stderr, “%sn”, m);exit(c);}while(0)
typedef enum{
NONE = 0,//no flags are passed in CLAs
CLEAR = 1,//-c
HEX = 1
Purchase answer to see full
attachment