Question: for the following code the output should be student@student:~ / CSC 4 1 5 / AssignmentCreation / CSVThreads$ make test . / Bierman _ Robert
for the following code the output should be student@student:~CSCAssignmentCreationCSVThreads$ make test
BiermanRobertHWcsv
Header Column : Name Last, First
Header Column : Age
Header Column : Favorite Color
Header Column : Comments
Data for line
Field : Bierman, Robert
Field :
Field : Blue
Field : What can I say, this is a large comment
Data for line
Field : Smith, John
Field :
Field : Green
Field : I want to have a multiple
line comment
Data for line
Field : Clark, Dwight "The Catch"
Field :
Field : Red & Gold
Field : NFC Championship
CSV Tests Passed
student@student:~CSCAssignmentCreationCSVThreads$ but the output is only GirmayMulugetaHWcsv
Header Column : Name Last, First
Header Column : Age
Header Column : Favorite Color
Header Column : Comments
Data for line
Field : Bierman, Robert
Field :
Field : Blue
Field : What can I say, this is a large comment"
Field Incorrect Should be: What can I say, this is a large comment
make: Makefile:: test Error
GirmayMulugetaHWcsvc
#include
#include
#include
#include "GirmayMulugetaHWcsvh
#define MAXLINELENGTH
#define MAXFIELDS
FILE csvfile NULL;
char header NULL;
char currentline NULL;
char currentfields NULL;
int numfields ;
char tokenizelinechar line
char tokens char mallocMAXFIELDS sizeofchar ;
char token;
int tokencount ;
const char delimiter ;
const char quote ;
const char escapedquote ;
token strtokline delimiter;
while token NULL
tokenstokencountchar mallocstrlentoken sizeofchar;
if token
strcpytokenstokencount token ;
while tokenstrlentoken
token strtokNULL delimiter;
if token NULL
Handle unexpected end of line
break;
strcattokenstokencount;
strcattokenstokencount token;
tokenstokencountstrlentokenstokencount;
else
strcpytokenstokencount token;
Handle escaped quotes
if strstrtokenstokencount escapedquote NULL
char pos strstrtokenstokencount escapedquote;
while pos NULL
memmovepos pos strlenpos ;
pos strstrpos escapedquote;
tokencount;
token strtokNULL delimiter;
tokenstokencount NULL;
return tokens;
char csvopenchar filename
char lineMAXLINELENGTH;
if csvfile fopenfilenamer NULL
return NULL;
if fgetsline MAXLINELENGTH, csvfile NULL
header tokenizelineline;
return header;
char csvnextvoid
char lineMAXLINELENGTH;
if fgetsline MAXLINELENGTH, csvfile NULL
currentfields tokenizelineline;
return currentfields;
return NULL;
char csvheadervoid
return header;
int csvclosevoid
int count ;
if csvfile NULL
fclosecsvfile;
csvfile NULL;
if header NULL
for int i ; headeri NULL; i
freeheaderi;
headeri NULL;
freeheader;
header NULL;
if currentfields NULL
for int i ; currentfieldsi NULL; i
freecurrentfieldsi;
currentfieldsi NULL;
freecurrentfields;
currentfields NULL;
return count;
can you fix it please
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
