Question: mt check is keep faild can some one help me please #include #include #include #include assignment 2 . h #define BLOCK _ SIZE 2
mt check is keep faild can some one help me please #include
#include
#include
#include "assignmenth
#define BLOCKSIZE Define the block size for buffer
int mainint argc, char argv
Check if commandline arguments are provided correctly
if argc
printfUsage: s
argv;
return ;
Allocate memory for the personalInfo structure
personalInfo pi personalInfo mallocsizeofpersonalInfo;
if pi NULL
printfError: Memory allocation failed
;
return ;
Allocate memory for first name and last name
pifirstName char mallocstrlenargv;
pilastName char mallocstrlenargv;
if pifirstName NULL pilastName NULL
printfError: Memory allocation failed
;
freepifirstName;
freepilastName;
freepi;
return ;
Populate the firstName and lastName fields
strcpypifirstName, argv;
strcpypilastName, argv;
Assign student ID replace with your actual student ID
pistudentID ;
Populate the level field you can choose appropriate value based on your level
pilevel SENIOR;
Populate the languages field include at least three languages
pilanguages KNOWLEDGEOFC KNOWLEDGEOFPYTHON KNOWLEDGEOFJAVA;
Copy the message from the third commandline argument
strncpypimessage, argv sizeofpimessage;
pimessagesizeofpimessage; Ensure nulltermination
Write personal information
if writePersonalInfopi
printfError: Writing personal information failed
;
freepifirstName;
freepilastName;
freepi;
return ;
Retrieve C strings and copy them into buffer
const char str;
while str getNext NULL
Allocate memory for buffer
char buffer char mallocBLOCKSIZE;
if buffer NULL
printfError: Memory allocation failed
;
freepifirstName;
freepilastName;
freepi;
return ;
Copy data into buffer using memcpy
sizet len strlenstr;
sizet copied ;
while copied len
sizet tocopy len copied BLOCKSIZElen copied : BLOCKSIZE;
memcpybuffer str copied, tocopy;
copied tocopy;
Commit the buffer
commitBlockbuffer;
Call checkIt function
int result checkIt;
Free the allocated memory
freepifirstName;
freepilastName;
freepi;
return result;
Assignmenth file is below ypedef struct personalInfo
char firstName;
char lastName;
int studentID;
enum gradelevel FRESHMAN SOPHMORE, JUNIOR, SENIOR, GRAD, INSTRUCTOR level;
int languages; See #defines for the bitmap values
char message;
personalInfo;
#define BLOCKSIZE
int writePersonalInfo personalInfo pi; Write your personal info structure
const char getNextvoid; Get the next line to buffer write
void commitBlock char buffer; Flush out your byte Buffer
int checkIt void; Called at the end of your program to check the results
#else
#error Do Not include header file assignmenth more than once
#endif
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
