Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

C array of pointers

A pointer is a variable that contains the memory location of another variable.

C array of pointers

                         

In this section, you will learn how to create array of pointers.

A pointer is a variable that contains the memory location of another variable. The values you assign to the pointers are memory addresses of other variables (or other pointers). A running program gets a certain space in the main memory. 

Syntax of declaring a pointer:

        data_type_name * variable name


First of all, specify the data type of data stored in the location, which is to identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Then specify the name of variable.

You can see in the given example, we have created an array of pointers of maximum size 3. Then we have assigned the objects of array pointer.
The address of the variable. 
array[0] = &x;
array[1] = &y;
array[2] = &z;

Here is the code:

ARRAYPOI.C

#include <stdio.h>
#include <conio.h>
main() {
  clrscr();
  int *array[3];
  int x = 10, y = 20, z = 30;
  int i;
  array[0= &x;
  array[1= &y;
  array[2= &z;
  for (i=0; i< 3; i++) {
    printf("The value of %d= %d ,address is %u\t \n", i, *(array[i]),
        array[i]);
  }
  getch();
  return 0;
}

Output will be displayed as:

ARRAYPOI.EXE

Download Source Code:

                         

» View all related tutorials
Related Tags: c file ant date get if txt ie example to exam ci ast e il last can pe in mod

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.