Hi, all~
Something result by sizeof method is 1, could that only contain 1 byte thing ?
Hi, all~
Something result by sizeof method is 1, could that only contain 1 byte thing ?
Last edited by black; 08-05-2002 at 05:26 AM.
Never end on learning~
The sizeof operator always returns the size of the variable in BYTES (not for dynamic or external arrays). So yes, it means the size is 1 byte.
shouldn't bools be by bits rahter than by bytes (waste of memory)?
---
now ever used a nibble yet?
think only with code.
write only with source.
Depends on what machine you are on. On intels booleans take up 4 bytes. You can use a character (1 byte) to store 8 booleans as toaster mentioned with the bits comment. You just have to remember which bits corresponds to which flag. Then just do some simple bit manipulation to check and set them.Originally posted by rmullen3
Yeah... booleans and characters are single bytes.
yep. And I just figure out my compiler could accept this line:Originally posted by MrWizard
Depends on what machine you are on. On intels booleans take up 4 bytes. You can use a character (1 byte) to store 8 booleans as toaster mentioned with the bits comment. You just have to remember which bits corresponds to which flag. Then just do some simple bit manipulation to check and set them.
Only the output show a single 'd'.PHP Code:
char x;
x='abcd';
cout << x << endl;
Never end on learning~
thats the way its supposed to be of courseOriginally posted by black
yep. And I just figure out my compiler could accept this line:
Only the output show a single 'd'.PHP Code:
char x;
x='abcd';
cout << x << endl;
hello, internet!