I keep getting errors, yet I'm following the style of my book!Code:struct cat { int bHungy = 0; /* "b" indicates boolean */ int bNeedto........ = 0; int bNeedto$$$$ = 0; int bWantpets = 0; int bWantfood = 0; } sugar;
I keep getting errors, yet I'm following the style of my book!Code:struct cat { int bHungy = 0; /* "b" indicates boolean */ int bNeedto........ = 0; int bNeedto$$$$ = 0; int bWantpets = 0; int bWantfood = 0; } sugar;
the $$$ is a censor that the board put up. In a less offensive way, teh $$$ stands for crap.
Alright... that makes sense... what errors are you getting?
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
i found my error. Appearantly, I can't define a variable while I'm also defining a structure. This code works:
I do have one other question: what headers do I need to make a bool variable?Code:struct cat { int bHungy; int bNeedto........; int bNeedtocrap; int bWantpets; int bWantfood; } sugar;
What? Why not have a boolean? It would be the smallest variable type - 1 bit. I would think that some things that programmers would want todo in C would only rely on true or false.
I saw that GCC supports some C99, but not all. Does any compiler support all?
Yes it would, but what would you do with the other 7, 15, or 31 bits in the stored location? Bools weren't defines in the original C. Gotta live with it.Originally posted by kinghajj
What? Why not have a boolean? It would be the smallest variable type - 1 bit. I would think that some things that programmers would want todo in C would only rely on true or false.
Use a char to cut down the space needed by the program if you think that's important. Or if you have multible bools to define, use each bit in a char to hold each boolean value.
Define the values as:
#define MEAT 0x01
#define MILK 0x02
#define VEGE 0x04
char boolValues = 0;
Set meat bit with
boolValues |= MEAT;
Clear milk bit with
boolValues &= ~MILK;
You can figure out how to test the value....
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers