Programming - Ch 17 Exercise Solutions
Modified March 24, 2009.
- Exercise 1:
What is the output format of pointer values on your implementation?
Hint: Don't read the documentation.
Solution code.
- Exercise 2:
How many bytes are there in an int? In a double? In a bool?
Do not use sizeof except to verify your answer.
Solution code.
- Exercise 3:
Write a function, void to_lower(char* s), that replaces all upper case characters in the C-style string s
with their lower case equivalent. For example "Hello, World!" becomes "hello, world!"
Do not use any standard library functions.
A C-style string is a zero-terminated array of characters,
so that if you find a char with the value 0 you are at the end.
Solution code.
- Exercise 4:
Write a function, char* strdup(const char*), that copies a C-style string into memory it allocates
on the free store. Do not use any standard library functions.
Solution code.