Friday 20, April 2018
Welcome Guest, Register | Login  
      Home       Tutorials       Free Ebooks       Free Scripts       Tech News       Articles       About Us       Blog        Forum

Pointers

A pointer is a variable suitable for keeping memory addresses of other variables; the values you assign to a pointer are memory addresses of other variables or other pointers.

C pointers are characterized by their value and data-type. The value is the address of the memory location the pointer points to, the type determines how the pointer will be incremented/decremented in pointer or subscript arithmetic.

Pointers are used to manipulate arrays and they can be used to return more than one value from a function.

Pointers are declared by using the asterisk(*).

 int *p;

Each variable has two attributes: address and value. The address is the location in memory. In that location, the value is stored. During the lifetime of the variable, the address is not changed but the value may change.

#include 

void main (void)
{
   int i;        
   int * a;     
   i = 10;       
   a = &i;  
    printf (" The address of i is %8u \n", a);         
    printf (" The value at that location is %d\n", i);  
    printf (" The value at that location is %d\n", *a);
}

Output:
The address of i is   631672
The value at that location is 10

The value at that location is 10

Arrays and Pointers:
An array is actually a pointer to the 0th element of the array. Dereferencing the array name will give the 0th element. This gives us a range of equivalent notations for array access. In the following examples, arr is an array.
Array
Pointer

arr[0]

*arr

arr[1]

*(arr+1)

arr[n]

*(arr+n)

 

 
 
C Language Tutorial
 
  Introduction
Introduction
  First Program
First Program
  Constants and Variables
Constants and Variables
  Loops
Loops
  Control Structure
Control Structure
  Functions
Functions
  Pointers
Pointers
  Arrays
Arrays
  Strings
Strings
  Structures and Unions
Structures and Unions
  File Handling
File Handling
  Graphics
Graphics
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download Cracking The Niche Code Ebook Cracking The Niche Code
   
Download Closing the Sale Ebook Closing the Sale
   
Download The Affiliate Marketers Master Guide Ebook The Affiliate Marketers Master Guide
   
Download 5 Simple Ways To Boost Up Your Website Ebook 5 Simple Ways To Boost Up Your Website
   
Download Affiliate Marketing Success Ebook Affiliate Marketing Success
   
Studiesinn.com 2018 All Rights Reserved.