Wednesday, February 23, 2011

Chapter 7 Exercises

The chapter 7 exercises kind of tied in with some of the things I had been learning in operating systems so I was excited to combine the two together to do these assignments.  


7.2.2: For this exercise, I had to create hello.c.punct and hello.c and you use the unix diff -U command to test the output. With the -U the diff command output is...


--- hello.c.punct       2011-02-23 13:48:18.000000000 -0500
+++ hello.c     2011-02-23 13:50:01.000000000 -0500
@@ -5,6 +5,6 @@
 #include <stdio.h>
 int main() {
-    printf("Hello, World.\n");
+    printf("Hello, World!\n");
     return 0;
 }
while the output without the -U looks something like this:
8c8
<     printf("Hello, World.\n");
---
>     printf("Hello, World!\n");

7.8: The next assignment was to create a file  that represents a new file, foo being created with the contents bar. So first I needed to copy the original bar files into bar.c.original and then edit bar.c. to contain the new patch information. The I used the command $ diff -u bar.orig.c bar > foo.patch which created a patch file with the contents of bar.

7.9: This assignment was to patch the echo command from the coreutils project so that it echoes out arguments in reverse order. Although this assignment was not hard since there is a walkthrough in the TOS book I still took my time  and read the directions very carefully. After I download the necessary files, it was time to edit echo.c. After making a copy of echo.c, I went and edited the statements that needed to be fix and created the patch. Of course after making the patch I had to test it and it worked!!!. I felt so accomplished.

No comments:

Post a Comment