Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

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 .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 20th, 2006, 12:53 AM
Registered User
 
Join Date: May 2006
Location: Redding, CA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ERRATA TOPIC

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.

SilverFoxtor
  #2 (permalink)  
Old May 24th, 2006, 01:18 PM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a similar problem but, unlike you, my addresses are 0012FF54 and 0012FF48 giving a difference of dec 12 when I compile and run the code. (This is with Visual Studio 2005 (version 8.0.50727.42.)

I even tried taking the example code and running it with Visual Studio, in case I had made a typing error.

Interestingly, if I run the same code through my Borland compiler, I get a difference of 4 bytes.

Is this a compiler error in Visual Studio?

Nick
  #3 (permalink)  
Old May 25th, 2006, 12:03 AM
Registered User
 
Join Date: May 2006
Location: Redding, CA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nick,

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.

SilverFoxtor
  #4 (permalink)  
Old May 25th, 2006, 03:28 PM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I went to the forums at msdn.microsoft.com/vstudio/support/forums/ and posted the question in Visual C++ General. V helpful people there came back with solution. Quoting vbvan:

'Because the flag "basic runtimes check"(/RTC1) is on by default.

When this flag is on, the complier will add some extra variables for check purpose.'

Reseting the flag produces 4 bytes intervals.

  #5 (permalink)  
Old May 26th, 2006, 01:53 PM
Registered User
 
Join Date: May 2006
Location: Redding, CA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

SilverFoxtor
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slightly off topic but how do I... Ceromus BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 0 October 21st, 2008 12:16 PM
My first topic codylee C# 2008 aka C# 3.0 1 January 3rd, 2008 08:05 AM
topic aparameshwar SQL Server 2000 6 July 11th, 2007 11:23 AM
Is this topic a professional topic?? mega ASP.NET 1.0 and 1.1 Professional 0 December 3rd, 2004 09:37 PM
Posted topic vrbhatt Forum and Wrox.com Feedback 3 September 24th, 2003 07:48 AM



All times are GMT -4. The time now is 03:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.