Module 4 CSC 201
Module 4 CSC 201
Objectives
By the end of this module, you will be able
to:
Understand working with strings
Implement pointers
int count = 7;
int *countPtr = &count;
The program and the pointer need to know what
type of variable-address the pointer contains.
A pointer variable is declared by specifying the
data type to which it will be pointing.
The asterisk operator (*) is used in the
declaration statement.
Pointers
The format:
data_type *variable_name;
Many naming conventions are used with pointer variables
to help the programmer remember which variables are
pointers.
Three conventions are listed below:
float *x_ptr; // use extension _ptr
float *pX; // use lowercase p with capital letter
float *p_x; // use prefix p_
Declaring int and double variables and pointers:
int a = 75;
int *a_ptr;
double b = 82.0;
double *b_ptr;
Pointers
addresses.
Summary