Hi I need help regarding the above question, ive tried to type: "DWORD file;" but the compiler says its undeclared. WHy? isnt DWord 32 bits? thks.

DWORD is not a standard C or C++ data type -- it is defined in windows.h. But if you want to use it without windows.h then you will have to declare it yourself as anything you want. For consistancy you might want to declare it as typedef unsigned long DWORD; . But that is no guarentee that it will be a 32-bit integer because the standards do not dictate the size of integers. Compilers are free to make them any size they want. So if that is a question you were asked then the answer is that there is no standard solution.

Edited 6 Years Ago by Ancient Dragon: n/a

>Compilers are free to make them any size they want.
Within limits. A long integer in C is absolutely required to be at least 32 bits, so as long as you you can ignore the bits of a larger size, you're solid. C99 introduces the <stdint.h> header where exact-size types are supported (int32_t in this case), if you need an exact type, it's probably a good reason to jump to C99. Otherwise you need to do what we did before: create a typedef and treat it as a non-portable aspect of the code.

If you have an array of 4 characters, then you have 32 bytes...
?

No you don't. What you have is an array of 4 bytes -- one character = one byte.

Thanks all for the suggestions.
@ Ancient Dragon: u have solved my problem. The compiler is able to declare after i included the windows.h. Thankz! :)

Hi another question:
Im actually writing a C program to read in wav files. How am i able to VERIFY if the wav file have been read correctly inside the C code? do i do a printf or something like that?

No you don't. What you have is an array of 4 bytes -- one character = one byte.

Right so you can store 1 byte in each character

Right so you can store 1 byte in each character

Something like that, but you store a character in one byte, not the other way around, but that has nothing to do with the topic of this thread because this thread is about integers, not character arrays.

Edited 6 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.