That was a typo that I later corrected. If all you want is the address, then great, it will work for you.Originally Posted by dwks
That was a typo that I later corrected. If all you want is the address, then great, it will work for you.Originally Posted by dwks
It's the only way to initialize (as Thantos says) a struct. It's the same as with arrays. Do you never do that either?You are one of a very select few who do. I've never see that before in over 20 years.
This code sets all elements to zero:
Code:int x[10] = {0};
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
The address is what I would expect, since it's a pointer.If all you want is the address, then great, it will work for you.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
No. Never like that, except maybe in an array of structures when initializers contain no function calls.Originally Posted by dwks
Do that all the time, but that's not the same as initializing a structure.Originally Posted by dwks
It's pretty much the same. They both initialize things. The only difference is that with structures, the type you're initializing can change.but that's not the same as initializing a structure.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
In C++ language, yes. I use BYTE because it's what I'm actually dealing with: bytes. Less confusing to me, and whoever I share my code with.Originally Posted by Thantos
Changing it to a char makes 50% of my bytes turn from 0x0000008E to 0xFFFFFF8E.how does it corrupt it?
Use & then to elininate the extra Fs.
[edit]How? With a cast?[/edit]Changing it to a char
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Impossible -- one byte cannot contain that big a number. The max falue of a byte is 0xff. you are probably seeing the output of a debugger, which is not necessarily the same as what is actually stored in the memory location.Originally Posted by Denethor2000
Obviously its causing more problems then its helping.In C++ language, yes. I use BYTE because it's what I'm actually dealing with: bytes. Less confusing to me, and whoever I share my code with
However you still haven't given up all the information. Or hell even a full code example. if all you need to do is write it out to a file use write() on a binary file
Perhaps he should be "changing" it to an unsigned char.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
What if you were dealing with 16 bit bytes? 32 bit bytes? They'd have a high value then that.Impossible -- one byte cannot contain that big a number. The max falue of a byte is 0xff.
BTW I'm guessing we all are assuming you are using the BYTE specified in the windows header. Can someone tell me if its a #define or typedef?
You have a point -- but have you ever heard of such an animal? Not to say there isn't one, but I doubt the OP is using it.Originally Posted by Thantos
Originally Posted by windef.h
Bytes are 2 bits. Words are 4 bits. Dwords are 8 bits. Qwords are 16 bits.
All bytes are 2bit, 0xFF. Stop asking if my bytes are 32bit or 16bit... They're neither, obviously.
Anyway, using memcpy lets me copy my array into the struct, and it works correctly. Thanks for the help. <3
No. on MS-Windows and *nix a byte is 8 bits. What you probably mean is a nibble, which is half the size of a byte.Originally Posted by Denethor2000
-- If you don't know what a byte is, don't bother reading. --
I guess you should never have started this thread, since you don't know what a byte is either
Ok you are seriously in need of some education then. Bytes are the lowest addressible memory element. By standard they are required to contain at least 8 bits. So whereever you got your size definations, burn it.