I'm pretty sure this is again something about C99, but how do I use booleans in C code in Visual Studio 2010?
I'm pretty sure this is again something about C99, but how do I use booleans in C code in Visual Studio 2010?
typedef int bool;
Or something similar.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
It gives me
IntelliSense: invalid combination of type specifiers
error C2065: 'false' : undeclared identifier
error C2065: 'true' : undeclared identifier
What I find strange is that it has "bool", "true" and "false" all blue, ie. it understands those are keywords, but doesn't know how to use them.
If you were using some C99 compliant compiler you could use the framework for booleans in stdbool.h . Sadly though, that is not the case with VS.
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
It can run on Windows, yes, but the huge reason why I use VS2010 here is
1) I happen to have VS2010
2) The thing that I'm trying to do here is to just learn the C as well as possible
One question, or thing that I'm looking reassurance for, is that if I use this "original C" that VS2010 uses, can I assume anything that can run C99 can run this "original" C as well just "as is"?