You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .

Errata:††"Beginning Visual C++ 2005" p. 175
The outupt of Ex4_05.cpp is shown near the bottom. The addresses of &number1 and pnumber are shown to be 0012FEC8 and 0012FEBC, respectively. If one calculates the difference between the two addresses (C8-BC), the difference = 0x0000000C or 12(dec). As pointed out on p. 176 just below the midpoint of paragraph 6, the difference between &number1 and pnumber should be 4 bytes since they occupy adjacent memory locations for each [u]type long</u> variable. The last sentence of paragraph 6, p. 176, "The output demonstrates that everything is working as you would expect", is not true for the output of Ex4_05.cpp as written on p. 175. The good news is that the compliled and executed code on my computer showed the correct 4-byte spread between the addresses of &number1 and pnumber.

I must admit that I did not use Visual Studio to complile the code for the Errata that I posted. I used the DevC++ compliler for this one and I got the correct 4-byte interval. Maybe someone with some expertise could explain why Visual Studio has a 12-byte interval.

Thanks for that research, Nick! One can see how the entry in the book is still misleading since it does not give this information or elude to Visual Studio giving an interval greater than 4 bytes for whatever reason. The author should not have refered to this 4-byte interval or adjacent memory locations at all, even though it is true with optimized code.