• C

how to use datatypes: word and dword in c


which include library do I need to have word and dword.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

typedef theTypeYouWantToUseForWord word;
typedef theTypeYouWantToUseForDword dword;
Dave BaldwinFixer of ProblemsCommented:
Neither one.  'word' and 'dword' are part of the language.
You might find some appropriate types to use in
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

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
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;
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
I type
no intellisense until I add
<minwindef.h> to the top of file

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.