CSC 373: Computer Systems I

Homework 3

Due by 11:50 am on Tuesday, February 11



Please write precise and concise answers.

Reading

Read chapters 5, 6, and 7 of KR*, sections 3.1-3.6 of BO* as well as week 4 and 5 lecture notes.

*BO = Computer Systems by Bryant and O'Hallaron
*KR = The C Programming Language by Kernighan and Ritchie

Make sure that you work out every practice problem in *BO!  Peek at the solutions (presented at the end of the chapter) if you have to.

Assignment

1.    Using the material at the end of Lecture1, write a C program that 1) opens a file named test.txt containing up to 1000 integers, one per line, 2) reads the integers one by one, 3) stores the integers in a dynamically allocated array of size 1000, and 4) prints the content of the array in a single line. Test you code on file /home/prof/public/test.txt. Your output should be:

$ gcc -o hw3 hw3.c
$ ./hw3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

..........

767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798


2.    Problem 3.54 in BO.

Please use the to discuss this assignment between yourselves, and also with me. Write your solutions in a .txt ASCII text file and submit them through COL.