0% found this document useful (0 votes)
6 views

C - Reference Card

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

C - Reference Card

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Reference Card Looping Pointers

while Loop Example A pointer variable (or just pointer) is a variable that stores a
C++ Data Types memory address. Pointers allow the indirect manipulation of
data stored in memory.
Data Type Description
boolean (true or false) Pointers are declared using . To set a pointer's value to the
character ('a', 'b', etc.) address of another variable, use the operator.
character array (C-style string if
terminated) Example
C++ string (from the STL)
integer (1, 2, -1, 1000, etc.)
do-while Loop Example
long integer
single precision floating point
double precision floating point
Use the indirection operator ( ) to access or change the
These are the most commonly used types; this is not a
value that the pointer references.
complete list.
Example
Operators
The most commonly used operators in order of precedence:
1 (post-increment), (post-decrement)
2 (not), (pre-increment), (pre-decrement) for Loop
3 , , (modulus)
4 , Array names can be used as constant pointers, and pointers
5 , , , can be used as array names.
6 (equal-to), (not-equal-to)
Example
7 (and)
8 (or)
9 (assignment), , , , ,
Example
Console Input/Output
console out, printing to screen
console in, reading from keyboard
console error Dynamic Memory
Example: Allocate Memory Examples
Functions
Functions return at most one value. A function that does not
return a value has a return type of . Values needed by
a function are called parameters.
File Input/Output
Example (input): Deallocate Memory Examples

Once a pointer is used to allocate the memory for an array,


array notation can be used to access the array locations.
Examples
Example
Example (output):

Structures
Decision Statements Declaration Example
if Example

if / else Example Passing Parameters by Value

Definition Example

Passing Parameters by Reference


switch / case Example

Accessing Members Example


Default Parameter Values

Structures can be used just like the built-in data types in


arrays.

You might also like