-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Description
Hello, Josh!
At example 3-7, I found something that I have a question.
1. #include <cstdio>
2. int main() {
3. char lower[] = "abc?e";
4. char upper[] = "ABC?E";
5.
6. char* upper_ptr = &upper[0];
7. *(lower + 3) = 'd';
8. *(upper_ptr + 3) = 'D';
9.
10. char letter_d = *(lower + 4); // lower decays into a pointer when we add
11. char letter_D = *(upper_ptr + 4);
12.
13. printf("lower: %s\nupper: %s", lower, upper);
14. *(lower + 7) = 'g';
15. }
The lines 10 and 11 points to offset 4, but I think the offset is 3. What do you think?
I have to mention that your book is fantastic! It has been a long time since I had found such an enjoyable approach. I have to say that your book became a bedside book. Thanks for your excellent work!
Regards from Brazil
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels