Overview
This week we will continue our study of the C programming language.
Thursday and Friday, December 11th and 12th
Classwork / Homework / Evaluation
We'll begin with the promised quiz. I'll also share STRING.H and TESTSTR.C. The rest of the class you can work on the next assignment.
Read Chapter 5: Pointers and Arrays beginning on page 89 through the end of Section 5.5: Character Pointers and Functions on on page 102 of The C Programming Language.
Then complete Exercises 5-2, which asks you to write a version of
strcat that uses pointers. Also write pointer versions of
atoi, itoa and reverse from
Exercise 5-4
To earn an A on your next evaluation, commits made both during class and between classes must contain evidence of the effective use of the 3 hours of time you have allotted to work on this, even if you can't complete it. This assignment is due Friday, December 12th at 11:59 pm for 3B and Saturday, December 13th at 11:59 pm for 1A so I have time to evaluate them before we meet next week. If you've been slacking, you need to put in more than 3 hours to make up for what you didn't do earlier!
Tuesday and Wednesday, December 9th and 10th
Start of Class
We will share the programs assigned for homework, and then pair you up for the next set of classwork / homework problems.
I'll then share a few programs which will be useful to you in completing your next assignment, including: PNUM.C, UCASE.C, and especially WRDLINE.C and WC.C.
I'll demo the last two of these and highly encourage you to study them!
Classwork / Homework / Evaluation
Please come to our next class with working solutions to the following problems:
Write a program in a file named
CHRNUMS.Cto prepend each line of a text file with the number of characters in that line. Given a file namedLINES.TXTwith content:This is a file containing lines of different lengths.
Running
CHRNUMS LINES.TXTwould print:15: This is a file 20: containing lines of 10: different 8: lengths.
- Complete Exercise 1-17 on page 28 of The C Programming
Language. Use the
reverse(s)function you complete in that exercise to write a program in a file namedBACKWARD.Cthat takes a text file as a command line argument and prints out each line in the file backwards.
Be prepared for a possible quiz on these two exercises when you arrive in class next time!