Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
Question About "ProgEx37 -- Windows GUI Programming . . ."

General Category > General Discussion

Question About "ProgEx37 -- Windows GUI Programming . . ."

(1/2) > >>

Seamus Decker:
I have a question about ProgEx37 -- Windows GUI Programming; Basic Template Program With Discussion. Did not see any questions or discussion in that thread, so I wasn't sure if it would be poor etiquette to post a question in that thread.

My question: When Frederick gets to the "tchar1.cpp" example, he states

--- Quote ---It gives precisely the same output as Ansi.cpp (1st little program above).
--- End quote ---

But for me, it doesn't. I've typed it in and copy-pasted it twice and I get:
//iLen             = 13
//sizeof(szBuffer) = 28

Not
//iLen             = 13
//sizeof(szBuffer) = 14

I have not yet fully digested that whole post, but this seemed like a non-trivial matter, i.e., "the generic functions and data types" are NOT reducing "simply to the ansi single byte char based functions."

Seamus Decker:
Well this is peculiar. The array itself is a 14 byte object, but for some reason the output says it is a 28 byte object. Comprehension of sorcery is behind this is above my pay grade I think, but this at least reconciles the inconsistency enough for me to let it go and carry on.

If anyone has a clarification for what is going on there, I appreciate it.

Paul Squires:
Is len reporting the number of characters (13) and sizeof the actual size of the string being unicode so it's two bytes per character (26) plus two bytes for the trailing nul terminating character (28)?.

James C. Fuller:
I emailed Fred and here is his response:


For some reason I can't seem to log in to Jose's Forum.  I seem to recall this happening before.  In any case, I finally found the post up in the main section of Jose's board, and it looks to me like the pre-defined symbol by Microsoft is causing the fellow's program to run as a UNICODE build as opposed to an ansi build, and that's why he is confused.  You are certainly aware of that issue, aren't you?  The issue is that when using Visual Studio  all builds are UNICODE unless one goes into the 'General Properties' window of the project, where one finds a dropdown where one can select ansi, wide character etc.  It defaults to wide character.  Since you and I work from batch files or command line, we don't have to deal with that.  Perhaps if you can log in you might mention that to the fellow?  He's worried about it.

Seamus Decker:

--- Quote from: James C. Fuller on August 09, 2019, 11:49:35 AM ---I emailed Fred and here is his response:


For some reason I can't seem to log in to Jose's Forum.  I seem to recall this happening before.  In any case, I finally found the post up in the main section of Jose's board, and it looks to me like the pre-defined symbol by Microsoft is causing the fellow's program to run as a UNICODE build as opposed to an ansi build, and that's why he is confused.  You are certainly aware of that issue, aren't you?  The issue is that when using Visual Studio  all builds are UNICODE unless one goes into the 'General Properties' window of the project, where one finds a dropdown where one can select ansi, wide character etc.  It defaults to wide character.  Since you and I work from batch files or command line, we don't have to deal with that.  Perhaps if you can log in you might mention that to the fellow?  He's worried about it.

--- End quote ---

That makes sense. I will examine it and I imagine it will fix it.

Thanks so much for the help, and also to Frederick Harris: huge thanks! for that tutorial "ProgEx37" tutorial 'series.' Slowly making progress in that, and it is exactly what I needed to move forward as a developer!

Based on the ~35k views of the thread, I am not alone!  :)

ADDIT: Whoo hoo! FIXED!  ;D

--- Code: ---iLen = 13;
sizeof(szBuffer) = 14
--- End code ---
In my experience, not knowing how to control the IDE "starship" is a big part of the problem, so I always prefer to walk through these complications and sort them out. I appreciate the help!

Navigation

[0] Message Index

[#] Next page

Go to full version