C++
Variables can be 'global' or 'local'.
short / short int
short integer (2 bytes)
int
integer (4 bytes)
long / long int
long integer (4 bytes)
bool
boolean (1 byte)
float
floating point number (4 bytes)
double
double precision floating point number (8 bytes)
char
Character (1 byte)
Operators
In C++ there are four main classes of operators:
Relational
>
, >=
, <
, <=
, ==
, !=
Logical
&&
, `
,
!`
Bitwise
&
, `
,
^,
~,
>>,
<<`
Expressions that use relational or logical operators return 0 or false and 1 for true.
0 value converts to false
non-zero values automatically converts to true
Iteration and Conditional Structures
Useful to instruct the program to execute or to repeat a specific operation when some condition is matched.
if
while
break
switch
for
continue
do-while
goto
return
Pointers
A pointer is a variable that holds a memory address. This address is the location of another object in memory.
If a variable is a pointer, it must be declared in a different way.
type
defines the type of variable the pointer can point to.*
is the complement of&
. It returns the value located at the address of the following operator.
Arrays
An array is a collection of variables of the same type, which is accessed by an index. All arrays have 0 as an index of the first element:
Functions Study Guide
Functions are blocks of statements defined under a name.
In almost any programming language, there are two ways in which we can pass arguments to a function:
By value
Copies the value of an argument into a parameter. Changes made to the parameter do not affect the argument
Code in the function does not alter the arguments used by the caller
It's a copy of the value of the argument passed into the function
What occurs inside the function has NO EFFECT on the variable provided by the caller
By reference
The address of an argument (not the value) is copied into the parameter
Inside the function, the address is used to access the actual argument used in the call
Changes made to the parameter will affect the argument
Example: Steals user's directory content
Listen for an incoming connection with nc -lvp 5555
:
Example: keylogger that sends any collected information back
Listen for an incoming connection with nc -lvp 5555
:
Last updated