Programming Assignment 5 Knight Foundation School of Computing and Information Sciences In this assignment, you are aske

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Programming Assignment 5 Knight Foundation School of Computing and Information Sciences In this assignment, you are aske

Post by answerhappygod »

Programming Assignment 5 Knight Foundation School Of Computing And Information Sciences In This Assignment You Are Aske 1
Programming Assignment 5 Knight Foundation School Of Computing And Information Sciences In This Assignment You Are Aske 1 (355.01 KiB) Viewed 34 times
Programming Assignment 5 Knight Foundation School Of Computing And Information Sciences In This Assignment You Are Aske 2
Programming Assignment 5 Knight Foundation School Of Computing And Information Sciences In This Assignment You Are Aske 2 (215.92 KiB) Viewed 34 times
DRAFT CODE GIVEN BY PROFESSOR
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#define MAX_LINE_LENGTH 1000#define MAX_CELL_LENGTH 20int main( int argc, char *argv[]){char inExt[4], outExt[4];char line[MAX_LINE_LENGTH];char cell[MAX_CELL_LENGTH];char* rest;if(argc < 5){fprintf(stderr, "too few args\n");exit(1);}else if(argc > 5){fprintf(stderr, "too many args\n");exit(1);}if(!strcmp(argv[1], "-i")){strncpy(inExt, argv[2], 3);strncpy(outExt, argv[4], 3);}else if(!strcmp(argv[1], "-o")){strncpy(outExt, argv[2], 3);strncpy(inExt, argv[4], 3);}else{fprintf(stderr, "Error: usage of converter: -i inExt -ooutExt\n");exit(1);}fprintf(stderr, "in format is %s, out format is %s\n", inExt,outExt);if(!strcmp(inExt, "csv") && !strcmp(outExt, "txt")){while(fgets(line, MAX_LINE_LENGTH, stdin)){while(sscanf(line,"%[^,\n],%[^\n]\n",cell , line) ==2)//(strchr(rest, ',')){printf("%s\t", cell);//internal cell followed by tabprintf("%s\n",cell);//last cell followed by new line}}else if(!strcmp(inExt, "txt") && !strcmp(outExt,"csv")){while(fgets(line, MAX_LINE_LENGTH, stdin)){while(sscanf(line,"%[^\t\n]\t%[^\n]\n",cell , line) ==2)//(strchr(rest, ',')){printf("%s,", cell);//internal cell followed by tabprintf("%s\n",cell);//last cell followed by new line}}}
PLEASE COMPLETE QUESTION 2 TOO (BONUS QUESTION) I'D APPRECIATE IT. I'D also appreciate if you can split theassignment into different C.files and headers files to make it moreorganize instead of only one file
Programming Assignment 5 Knight Foundation School of Computing and Information Sciences In this assignment, you are asked to write a program that gets a tabulated textual data from input stream, changes its format to another format. It should support the following formats: - .csv (comma separated values): stores tabular data in plain text. Each line of the text represents a table row containing one or more cells separated by commas. - .tl5: stores tabular data in plain text. Each line of the text represents a table row containing one or more cells separated by 'l' character. Each cell is 5-characters long and contains a left-aligned string. If the string stored in a cell has n<5 characters, the rest of it will be filled with spaces; i.e. there will be 5−n extra space characters in the field after the string. However, if a string with more than 5 characters is supposed to be placed in a cell, only its first 5 characters is stored in the cell. 1 Command-Line Arguments and Options Your program may be executed with one or more command-line arguments (options). It must support the following options: - -i xxx : where xxx is either csv or tl5. This option specifies the format of input data. - -o yyy: where yyy is either csv or t15. This option specifies the format of output data. 250% Bonus Part As the bonus part, the program must support the following formats specified below: - tr9 : stores tabular data in plain text. Each line of the text represents a table row containing one or more cells separated by ' l ' character. Each cell is 9-characters long and contains a right-aligned string. If the string stored in a cell has n<9 characters, the rest of it will be filled with spaces; i.e. there will be 9−n extra space characters in the cell before the string. However, if a string with more than 9 characters is supposed to be placed in a cell, only its last 9 characters is stored in the cell.
- .tc9: stores tabular data in plain text. Each line of the text represents a table row containing one or more cells separated by ' ∣ ' character. Each cell is 9 -characters long and contains a center-aligned string. If the string stored in a cell has n<9 characters, the rest of it will be filled with spaces; i.e. there will be ⌊29−n​⌋ extra space characters in the cell before the string and ⌈29−n​⌉ extra space characters in the field after it. However, if a string with more than 9 characters and odd length is supposed to be placed in a cell, only its middle 9 characters is stored in the cell. In the case that the length of original string is even and greater than 9 , its middle 8 characters must be stored in the cell (plus an extra space character). 3 Submissions You need to submit a .zip file compressing the C source file(s) related to the assignment (.c files), header files ( .h files), makefile and a readme.txt file specifying which of the following conversions are supported by your program:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply