Question: In C Download the code for the following program, task1.c, then compile and run it. Describe in detail (3-4 sentences) what the program do es,

In C

In C Download the code for the following program, task1.c, then compileand run it. Describe in detail (3-4 sentences) what the program do

Download the code for the following program, task1.c, then compile and run it. Describe in detail (3-4 sentences) what the program do es, by adding a comment at the beginning of the code. 11/ taski.co/ #include #include 5 #include #include #include #include /* change to for System V / 9 11 struct student { int sequence_num char authcate [8]; 16 char authca tes [] {"abcd001", "life042", "ismi123", "jbon 777"}; int main(int arge, char *argv []) 19 int i, outfile; struct student each rec; 21 open ("result", O_WRONLY | O_CREAT | O_TRUNC, 0664)) = 0; i -=2) { eachrec. sequence_num= i; strcpy(eachrec.authcate, authca tescil): Iseek outfile. (long) i *sizeof(struct student). SEEK_SET ); write (outfile. &eachrec, sizeof(struct student)); 29 30 31 52 33 1) { i 4; } } 36 37 38 close (outfile); exit(0); 39 By modifying the program that you have understood in Task 1 (Section 3.1), write a C program that uses system calls for 1/O and does the following: Reads the student structs from the result file in the following order: the second record (1), the first record (0), the last or fourth record (3), and the third record (2) Prints all student authcates out on the terminal screen Writes the authcates of students with an odd sequence number value to a file called odd. Writes the authcates of students with an even sequence number value to a file called even. Hint: As you may have noticed, not all data in a file like result can necessarily be displayed in a text editor like pluma. Text editors work by treating each byte in a file as a character code, and displaying that character on the screen. For making sense of non-character data in a file, you may wish to use the ghex application in your Linux environment, which displays the actual numerical values of binary data stored in a file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!