From Wikibooks, open books for an open world
This page may need to be
reviewed for quality.
Preprocessor
|
#include <stdio.h> |
includes contents of stdio.h
|
#error text |
display text as compile time error
|
#warning text |
display text as compile time warning
|
#pragma |
compiler specific options
|
#define M |
define M
|
#undef M |
undefine M
|
#if (condition) |
conditional compiling
|
#ifdef M |
compiled if M is defined
|
#ifndef M |
compiled if M is not defined
|
#elif (condition) |
conditional compiling
|
#else |
conditional compiling
|
#endif |
end conditional section
|
defined() |
is macro defined.
|
!defined() |
is macro not defined
|
M ## D |
combines M and D into MD
|
#M |
treat M as string "M"
|
|
Syntax
|
if (bool expr) block [else block]
|
for ([expr];[condition];[expr]) block
|
while (condition) block
|
do { } while (condition)
|
type identifier([type identifier, ...]);
|
type identifier([type identifier, ...]) { }
|
class identifier [:[private|public] type, ...];
|
class identifier [:[private|public] type, ...] { [private:] };
|
struct identifier [:[public|private] type, ...];
|
struct identifier [:[public|private] type, ...] { [public:] };
|
union identifier;
|
union identifier { type identifier; ... };
|
enum identifier;
|
enum identifier { identifier [=int_value], ... }';
|
typedef type identifier;
|
|
Logical AND (&&) and Logical OR (||) Lookup Table
Logical OR:
OR |
True |
False |
True |
True |
True |
False |
True
|
False |
Logical AND:
AND |
True |
False |
True |
True |
False |
False |
False |
False |
Logical XOR:
XOR |
True |
False |
True |
False |
True |
False |
True |
False |
|