Click here to Skip to main content
15,890,579 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is it possible to have an array of types ? Pin
Defenestration9-Dec-08 1:27
Defenestration9-Dec-08 1:27 
QuestionRe: Is it possible to have an array of types ? Pin
David Crow9-Dec-08 3:14
David Crow9-Dec-08 3:14 
AnswerRe: Is it possible to have an array of types ? Pin
Michael Dunn9-Dec-08 13:52
sitebuilderMichael Dunn9-Dec-08 13:52 
QuestionHow to unblock pipe write operation? Pin
sashoalm8-Dec-08 21:39
sashoalm8-Dec-08 21:39 
QuestionNeed some Bits/Bytes and Types information Pin
gabbana8-Dec-08 21:24
gabbana8-Dec-08 21:24 
AnswerRe: Need some Bits/Bytes and Types information Pin
CPallini8-Dec-08 22:16
mveCPallini8-Dec-08 22:16 
AnswerRe: Need some Bits/Bytes and Types information Pin
Code-o-mat8-Dec-08 22:22
Code-o-mat8-Dec-08 22:22 
AnswerRe: Need some Bits/Bytes and Types information Pin
gabbana8-Dec-08 22:32
gabbana8-Dec-08 22:32 
Okay, now I think i found some information.

Lets start with Bits and Bytes:

A BIT can be 1 or 0. So we have 2 options
A BYTE contains 8 Bits. So we have 2^8 possible option (ASCII/ANSI) So we have all the 256 chars.
A WORD contains 16 Bits (2BYTE)
A WCHAR (wide char) contains also 16bits (2BYTE) -> chinese languag and so on need 2 Bytes for one char.

A Pointer (I said its normally a void point but that was wrong) is normally a pointer to a specific datatype, for example WCHAR *buf -> means we have a Pointer which points to ONE WCHAR somewhere in memory (as long as we allocate space)

So now we allocate space: *buf = new WCHAR[16]; This means we allocate 16 bits per char, so we have allocated 2*16 bytes = 32 bytes which means 2^32 bits.

So if we use the example with edit field, we get an integer (the length) and convert it to a WORD. BECAUSE the edit field must return something >0 we CAN convert it to an unsigned integer, a WORD right?

-> Now why do we need the following?
*((LPWORD)buf) = length

And why does
*(buf) = (WORD)length

also works ?

So we know that WCHAR contains 2Bytes. A WORD also contains 2Bytes.
So the point normaly shows to the firt wchar which is also a WORD in this example. So we can easily move the length to this location. Right ?

But why the first way ?
So it could be that if we does not using unicode, the pinte would only show to the first ONE byte in the memory. And then we need to convert it it first to an LPWORD to be sure the pointer shows to the FIRST 2Bytes, a WORD in memory. And so it works.


I hope its not too long and someone can confirm my explanation.

Thank you very much.

bye,
gabbana
GeneralRe: Need some Bits/Bytes and Types information Pin
gabbana8-Dec-08 22:35
gabbana8-Dec-08 22:35 
GeneralRe: Need some Bits/Bytes and Types information Pin
Code-o-mat8-Dec-08 23:00
Code-o-mat8-Dec-08 23:00 
GeneralRe: Need some Bits/Bytes and Types information Pin
gabbana9-Dec-08 0:51
gabbana9-Dec-08 0:51 
Questiondifference between CreateThread & AfxBeginThread Pin
Nikesh Jagtap8-Dec-08 21:17
Nikesh Jagtap8-Dec-08 21:17 
AnswerRe: difference between CreateThread & AfxBeginThread Pin
Roger Stoltz8-Dec-08 21:27
Roger Stoltz8-Dec-08 21:27 
AnswerRe: difference between CreateThread & AfxBeginThread [modified] Pin
Defenestration8-Dec-08 22:32
Defenestration8-Dec-08 22:32 
AnswerRe: difference between CreateThread & AfxBeginThread Pin
Roger Stoltz8-Dec-08 22:42
Roger Stoltz8-Dec-08 22:42 
GeneralRe: difference between CreateThread & AfxBeginThread Pin
Defenestration8-Dec-08 22:51
Defenestration8-Dec-08 22:51 
QuestionHow to write string values in .csv file Pin
MsmVc8-Dec-08 20:40
MsmVc8-Dec-08 20:40 
AnswerRe: How to write string values in .csv file Pin
Cedric Moonen8-Dec-08 20:51
Cedric Moonen8-Dec-08 20:51 
AnswerRe: How to write string values in .csv file Pin
SandipG 8-Dec-08 20:52
SandipG 8-Dec-08 20:52 
GeneralRe: How to write string values in .csv file Pin
MsmVc8-Dec-08 21:10
MsmVc8-Dec-08 21:10 
QuestionRe: How to write string values in .csv file Pin
Rajesh R Subramanian8-Dec-08 21:01
professionalRajesh R Subramanian8-Dec-08 21:01 
QuestionWindows Installer for a C++/MFC application Pin
Puneet Kulkarni8-Dec-08 19:46
Puneet Kulkarni8-Dec-08 19:46 
QuestionWhy do some combinations of port settings fail ? Pin
kapardhi8-Dec-08 19:34
kapardhi8-Dec-08 19:34 
AnswerRe: Why do some combinations of port settings fail ? Pin
Roger Stoltz8-Dec-08 21:43
Roger Stoltz8-Dec-08 21:43 
QuestionSafe way to initialize LARGE_INTEGER with int ? PinPopular
Defenestration8-Dec-08 18:42
Defenestration8-Dec-08 18:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.