Save
...
Computer Programming 2
Week 7 to 8 Pointers in C++
Pointer Initialization
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Marc
Visit profile
Cards (10)
Pointer Initialization
Syntax:
dataType *pointerName = &variableName;
where:
& - the ampersand (&) symbol is used to get the memory address of a variable called as address-of operator.
variableName - is a unique identifier name for the that has the same data type as the pointer variable.
Pointer Initialization Syntax:
dataType *pointerName = &variableName;
where:
& - the ampersand (&) symbol is used to get the memory address of a variable called as address-of operator.
variableName - is a unique identifier name for the that has the same data type as the pointer variable.
Pointer Initialization Syntax:
dataType *pointerName = &variableName;
where:
&
- the
ampersand
(
&
) symbol is used to get the memory address of a variable called as address-of operator.
variableName
- is a unique identifier name for the that has the same data type as the pointer variable.
Pointer Initialization Syntax:
dataType *pointerName = &variableName;
where:
& - the ampersand (&) symbol is used to get the memory address of a variable called as
address-of operator
.
variableName - is a unique identifier name for the that has the same data type as the pointer variable.
int *ptrInt = 0;
/* ptrInt doesn’t point to any valid memory location, 0 is the only integer value can be used to assign an empty pointer address */
int *ptrInt = 0; /* ptrInt doesn’t point to any valid memory location,
0
is the only integer value can be used to assign an
empty
pointer address */
int *ptrInt = NULL;
or
int *ptrInt = nullptr;
// NULL and nullptr are reserved words that doesn’t point to any valid memory location like 0 */
int *ptrInt = NULL; or int *ptrInt = nullptr; //
NULL
and
nullptr
are reserved words that doesn’t point to any valid memory location like 0 */
int num;
int *ptrInt = #
// ptrInt holds the address of num variable using address-of (&) operator
int num;
int *ptrInt = #
// ptrInt holds the address of num variable using
address-of
(
&
)
operator