?
Solved

how to use datatypes: word and dword in c

Posted on 2014-08-21
6
Medium Priority
?
1,760 Views
Last Modified: 2014-08-21
#include<stdio.h>
#include<string.h>

which include library do I need to have word and dword.
0
Comment
Question by:rgb192
6 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 40276782
typedef theTypeYouWantToUseForWord word;
typedef theTypeYouWantToUseForDword dword;
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40276788
Neither one.  'word' and 'dword' are part of the language.
0
 
LVL 85

Expert Comment

by:ozo
ID: 40276793
You might find some appropriate types to use in
<stdint.h>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 32

Expert Comment

by:phoffric
ID: 40276912
Did you mean DWORD and WORD rather than dword and word?
In any case, none of these four tokens are part of the ANSI C language. DWORD and WORD are created by Microsoft so that if you use them, you will have more trouble porting to other systems, and be stuck using Microsoft. Do avoid them if you do not need them.

From http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
DWORD
A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.

This type is declared in IntSafe.h as follows:

typedef unsigned long DWORD;
 
WORD
A 16-bit unsigned integer. The range is 0 through 65535 decimal.

This type is declared in WinDef.h as follows:

typedef unsigned short WORD;
 
The size of long is implementation dependent. Maybe Microsoft constrains long to be 32-bits.
0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 2000 total points
ID: 40276927
It's totally compiler dependent.  

Data types like BYTE, WORD, DWORD are NOT a part of the C/C++ language standard.  They also are not a part of the standard C/C++ library standard.

It's totally possible that your compiler doesn't have any .h file that defines these data types.  After all, my Microsoft Visual Studio C/C++ compiler defines them in <minwindef.h>, a file your compiler likely does not have.

So you can either do a search of the .h files that came with your compiler, or you can do some trial and error with the sizeof() operator on your compiler and create your own typedefs to define these data types.

BTW, my current C++ compiler defines these datatypes like this:
typedef unsigned long DWORD
typedef unsigned short WORD
typedef unsigned char BYTE

These typedefs might or might now work for you as they assume that a long is 32-bit, and short is 16-bit.
0
 

Author Closing Comment

by:rgb192
ID: 40277223
I type
dword
no intellisense until I add
<minwindef.h> to the top of file

thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question