Interesting.

by Michael Calkins (Login MCalkins)
C-Forum

 

I hadn't quite grasped that the array name itself, without the use of any subscript, is a pointer.

So, I could use either:

Filename

or:

&Filename[0]

but I suspect that the former is better.

So, Filename is a pointer to a WCHAR, while Filename[0] is a WCHAR... (Which makes since, since array subscripting is pointer arithmetic.)

Thank you. Regards,
Michael

P.S. Why didn't the program fail? If it was getting a pointer to a pointer when it didn't expect that, it should have failed, I would think... (Specifically, it should have overwritten the pointer being pointed to. But I'm not sure that an actual pointer for Filename would even need to be stored in memory in the first place... Does C store pointers to all arrays in memory? I would probably have thought of them as compile time constants, which should not need to take up any space in the program at run time, except in the machine code itself. I guess I need to do more research.)



    
This message has been edited by MCalkins on Sep 15, 2011 12:34 AM

Posted on Sep 15, 2011, 12:25 AM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Re: Interesting.ComputerGhost on Sep 15
 Re: Interesting.Michael Calkins on Sep 15
  Re: InterestingComputerGhost on Sep 15
   Re: InterestingMichael Calkins on Sep 16
  * const data goes in .rdata, not .textMichael Calkins on Aug 22

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement