What is Pointer - C Pointer

C examples for Pointer:Introduction

Introduction

A pointer variable contains the memory address of another variable.

Pointers are declared with an asterisk * placed between the data type and the pointer's name.

The data type used determines what type of memory it will point to.

int* p; /* pointer to an integer */
int *q; /* alternative syntax */

A pointer can point to a variable of the same type.

The ampersand is the address-of operator (&).

Demo Code

#include <stdio.h>
int main(void) {
    int i = 10;//from w  ww  .  ja va 2s .  co m
    int* p; /* pointer to an integer */
    p = &i; /* address of i assigned to p */
}

Related Tutorials