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

Solved
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

  • Votes
  • Date
  • Descending date
  1. Contributor
    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
    1. 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!
  2. 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;
    1. 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!
  3. 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.
    1. 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).
    2. Contributor
      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.
    3. 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...
    4. @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.
    5. Contributor
      Anonymous,
      No byte is not equal to octet...