Type DWORD in C/C++ what is it???

Solved
little_titi Posted messages 250 Status Member -  
 crazydieter -
Hello,

I would like to know what a DWORD variable in C/C++ corresponds to? What is it used for?

Thank you!

--
The speed of light is faster than the speed of sound, which is why some people appear bright before they look stupid!
Configuration: Windows XP Firefox 2.0.0.17

3 answers

  1. Char Snipeur Posted messages 10112 Registration date   Status Contributor Last intervention   1 331
     
    DWORD, it must be double word, it corresponds to a variable of a certain number of bytes or bits.
    I believe the word is 4 bytes, the double word should be 8.
    It is used to know the size of the variable regardless of the C implementation.
    --
    Greetings! I used to think, now I am sure.Jesus Christ
    Char Sniper
    17
    1. little_titi Posted messages 250 Status Member 7
       
      Hey, hello again Char sniper! How are you? ;)

      I saw that DWORD is similar to longWord, which is a 32-bit unsigned word. I also think that the D stands for double, as you mentioned. Apparently, these types are used in the context of Windows applications, or at least that's what I understood.

      Thanks for the info! See you soon!


      --
      The speed of light being faster than the speed of sound explains why some people appear so bright before they look dumb!
      0
  2. toto
     
    Hello

    When a word like DWORD is not part of the standard C, it is defined in some .h file. Just right-click on DWORD and choose "GOTO definition of DWORD".
    VC++ will take you to windef.h at the line:
    typedef unsigned long DWORD;
    14
    1. little_titi Posted messages 250 Status Member 7
       
      Okay, thanks! I just looked at what you told me, and indeed we can see it that way!
      --
      The speed of light being faster than that of sound explains why some people seem so bright before they look stupid!
      0
  3. John
     
    Just for the record... Octet: 1 byte. Are we good so far?
    Word: 2 bytes.
    DWord: 4 bytes.
    D: Double
    No relation to Windows applications.
    And for the rest, there's Google. No need to code if you can't figure that out, nor to succeed in searching for it otherwise.
    6
    1. Truth
       
      Uh... don't read what John is writing, he's saying peanuts.
      For me, I have:
      typedef unsigned long DWORD;
      And as far as I know, a long has never been 2 bytes but rather 4 or 8 bytes (depending on the machine architecture: see http://www.cppfrance.com/forum/sujet-VAUT-SIZEOF-LONG_1078951.aspx).
      0
    2. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
       
      Truth,

      I do not agree with you. Moreover, if you read carefully, John did not say that DWORD is 2 bytes, but he said 4.
      I will add my comment:
      DWORD is not native in C; it is a type defined in the header windows.h. It can be an unsigned long, but not necessarily; it could be, why not, an unsigned long long (in C99). Furthermore, we do not talk about bytes for a type but rather byte (knowing that in C, bytes are at least 8 bits).
      The size of DWORD, therefore, depends on several criteria.
      1
    3. Hugooguh
       
      Since DWORD is defined in windows.h, I can’t see how it could be used in a system where a byte is not 8 bits... In fact, it’s just a legacy from the time when C had to adapt to many different and exotic processors, but today a processor with a byte different from 8 bits is quite rare...
      0
    4. Anonymous
       
      @Truth
      1 bit [fr/eng] != 1 octet [fr] == 1 byte [eng] == 8 bits
      And this, no matter the machine. It's just a matter of terminology, but it's still important if we want to communicate effectively.
      It's the classic situation. After a while, we don't even know what we're talking about anymore...

      @Hugooguh
      I agree.
      0
    5. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
       
      Anonymous,
      No byte is not equal to octet...
      0