Free Online Articles Directory
18.11.2008 Sign In Register Hello Guest
Email:
Password:
Remember Me 
forgot your password?


Effetive Use of Pointers

Author: varadarajan t Author Ranking Blue | Posted: 27-09-2008 | Comments: 0 | Views: 23 | Rating:  (183) Article Popularity - Blue (?) Got a Question? Ask.
Sign Up Now!

Abstact :

     This article shows an impotance of pointers. pointer is nothing but variables which can hold address. pointer variable need memory address as its value. we can't stotre direct value in pointer variables. Understanding pointer has  litle confusion to beginers but there's no real magic to pointers, and a lot of readers will already be familiar with their use. The only peculiarity of C is how heavily it relies on the use of pointers, compared with other languages, and the relatively permissive view of what you can do with them.

 

Declaring pointers

Pointer is a variable so  just like other variables, you have to declare pointers before you can use them. Pointer declarations look much like other declarations: but don't be misled. When pointers are declared, the keyword at the beginning (c int, char and so on) declares the type of variable that the pointer will point to. The pointer itself is not of that type, it is of type pointer to that type. A given pointer only points to one particular type, not to all possible types. Here's the declaration of an array and a pointer:

  example:

      int *p, *name, *ptr;

      int x, *pt;    // Declare with other variables also.

Once pointer has been declared we must initialize pointer variable before use.

      p = &x;

     pt= name;  //  name is array variable of type char

                     //  all array variable name can directly assign to pointer variables

Example for array : int ar[5], *ip; ip = &ar[3];

In that example, the pointer is made to point to the member of the array ar whose index is 3, i.e. the fourth member. This is important. You can assign values to pointers just like ordinary variables; the difference is simply in what the value means. The values of the variables that we have now are shown in Figure  (?? means uninitialized).

      ar[0]    ar[1]   ar[2]

the avove three array variables can have continious memory locations.  these variables can initialized indiviualy or by single statement like this.

     ar[0] = &x;    ar[1]= &y;  ar[2]=&z;

      or

   ptr=ar;    // normal initializtion

 

   Example program.

#include
#include
main(){
      int x, *p;

      p = &x;         /* initialise pointer */
      *p = 0;         /* set x to zero */
      printf("x is %dn", x);
      printf("*p is %dn", *p);

      *p += 1;        /* increment what p points to */
      printf("x is %dn", x);

      (*p)++;         /* increment what p points to */
      printf("x is %dn", x);

      exit(EXIT_SUCCESS);
}

 

 

Rate this Article: Current: 0 / 5 stars - 0 vote(s).

Article Source: http://www.articlesbase.com/programming-articles/effetive-use-of-pointers-580449.html

Print this Article Print article   Email to a Friend Send to friend   Publish this Article on your Website Publish this Article   Send Author Feedback Author feedback  
About the Author:

pointers in c - yashwant kanitkar
programming in c - E balagurusamy
sprit of c - Mullish , Hopper

Submitting articles has become one of the most popular means to drive traffic to your website and promote yourself and your business. Join us today - It's Free!

Article Comments

Comment on this article Comment on this article
Your Name
Your Email:
Comment Body
Enter Validation Code: Captcha


Related Articles

Direct Mail Sales Letters Flow Better With Subheads
By: Alan Sharpe | 12/09/2005 | Direct Mail
Use subheads anyway? Because you can't just cover the important points in your copy. You've got to highlight key points using graphic devices, such as bold type, italics, underlining,.

How to find the perfect home business?
By: Carl Cholette | 15/09/2005 | Home Business
A home business! 1. Company reliability: Look for a company or an association that's been in business for at least 5 years. With a good track record and good management..

Learn to Play the Piano the Easy Way
By: Carlos Semilla | 20/10/2005 | Music
Here are some pointers to help you on your journey in learning to play the piano...

Small Game Hunting and your Safety in the Wilderness
By: Wayne Foster | 14/09/2006 | Sports & Fitness
Keep yourself and others safe when hunting with firearms.

10 Pointers for Navigating With your Vehicle in Ice and Snow
By: Kathy Steinemann | 01/03/2007 | Travel Tips
Even so-called 'hot' areas like Florida can be hit with cold temperatures which result in frost and black ice on highways. Wherever you travel, you should be aware of how to cope with winter-like conditions. The tips in this article will help.

10 More Pointers for Navigating your Vehicle in Ice and Snow
By: Kathy Steinemann | 04/03/2007 | Travel Tips
This is the second in a series of articles containing useful tips for coping with frost, ice, and snow while you travel by vehicle. Be like the proverbial Boy Scout - advance preparation can save you time, aggravation, and cash.

More Pointers for Driving a Vehicle in Ice and Snow: Tires
By: Kathy Steinemann | 12/03/2007 | Automotive
This is the third in a series of articles containing useful pointers for coping with frost, ice, and snow while you travel by vehicle. The correct tires can make the difference between an enjoyable trip and a hefty towing or hospital bill.

Making the Most of your Credit Card
By: Reno Charlton | 25/07/2007 | Credit
Learn how to make the most from your credit card - and keep your pockets lined instead of your bank manager's! Following simple tips and pointers when using credit cards - such as making sure you have the right card and knowing what those pesky terms and conditions mean - can really save you money, if not see you start making some back!

Got a Question? Ask.

Ask the community a question about this article:

Frequently Asked Questions

Quality docking station for in-home use with the microsoft zune 80g?
By: Deana | 22-07-2008
what is a good quality ..not those cheap ones....docking station for in-home use with the microsoft zune 80g? thanks so much

Save as glitch on windows vista
By: Hans | 21-07-2008
In trying to save pictures from 'flickr', the files only contain an "X" and no actual picture, but no error message. I can still save them on my old XP system, though. How can I fix the 'save as' glitch on vista?

Vista 'save as' glitch
By: Hans | 21-07-2008
In attempting to save pictures from 'Flickr', in windows vista, the picture does not appear, other than as an 'X'. I must use my old computer to save any pictures and then transfer them to the vista computor. What can be done to fix this problem in vista?

I recived e=mail for (microsoft lottey) do you ...
By: theron | 29-06-2008
I recived e=mail for (microsoft lottey) do you have a lottery going on and should I trust this e-mail. the aderss is (microsoft deliveryawordsteam @gmail.com.

How to Install .Net framework 3.5 on Microsoft ...
By: veasnamuch | 19-06-2008
How to Install .Net framework 3.5 on Microsoft Windows Server 2003 , Enterprise Edition (5.2, Build 3790) (3790.srv03_rtm.030324-2048)?. My windows 2003 server doesnt have any service pack installed and when I Install .Net framework 3.5 on it, it said I need to update my windows to service pack 1. I cant updated the request service pack on my server due to verious application have been in production on it and I am very afraid of effection to those application with security and some other restriction which have fixed on the service pack 1 of windows 2003 server. Could any body tell me how can I do to install .Net framework 3.5 on Windows 2003 server(no service pack) like what my server is configured now? Thanks in advance, Veasna

How can i setup my email account with microsoft ...
By: doris | 17-06-2008
how can i setup my email account with microsoft outlook 2007

Q&A Powered by:
Powered by Yedda 

Latest Programming Articles

Cool Desktop Wallpapers
By: Danny | 18/11/2008
Cool desktop wallpaper is accomplishments arrangement that displayed in the computer operating system. The wallpapers usually be acclimated in JPEG, BMP and GIF book formats. That wallpaper can be acclimated with Microsoft Windows, Linux and Macintosh Mac OS. Each adviser can be altered requirements, alike admitting wallpaper images advised for accepted monitors can be scaled up or bottomward to the fit size. Those are accessible on the internet for free. Some categories of wallpapers are a

Tips for Buying Software Online
By: Daniel Jowssey | 17/11/2008
Buying software online not only helps save the planet, it also has other benefits, including: * Ease and Simplicity. You can purchase software in your underwear at 4am if you really want to. Shopping online doesn’t have to be done within regular business hours, nor do you need to look your best to do it. It’s also easy to shop around for the best prices and takes less time than driving to the shops.

Mvc Design Pattern
By: TuVinhSoft .,JSC | 14/11/2008
Model-view-controller (MVC) is an architectural pattern used in software engineering. In complex computer applications that present a large amount of data to the user, a developer often wishes to separate data (model) and user interface (View) concerns, so that changes to the user interface will not affect data handling, and that the data can be reorganized without changing the user interface.

Advantages of Low Cost Contract Programmers in Freelance Programming
By: Joanna Gadel | 12/11/2008
It observed that web industry is getting tougher thus the necessity of freelance contract programmer is required for developing more effective website with flexible features. This article states the fruitful advantages of freelance programmers in contract programming.

A Guide to Cnc Kits
By: Martin Applebaum | 09/11/2008
CNC kits are a way in which to construct your CNC machine. This article will provide some information on these machines.

A Guide to Cnc Tube Bending Machines
By: Martin Applebaum | 08/11/2008
Are you familiar with a CNC tube bending machine? This article will shed some light on the main function and components of this machine.

Ways to Hire Dedicated Php Programmers
By: Jucick | 08/11/2008
It’s not at all easy to hire dedicated PHP programmers unless you know where and how to find them. Whether you need to fix, update or enhance your website you naturally want the job done quick and right.

Top 4 Reasons Why Addressing Web Accessibility is Important
By: Matt Cave | 05/11/2008
There are very high chances that web accessibility is more important to the performance of your web site than you realize. Article takes a look at the top 4 reasons why it would be important to address the issue of web accessibility.

More from varadarajan t

Bitlevel Operations in C
By: varadarajan t | 27/09/2008 | Presentation
bit level programming is an one of the important concept in c and c++. it shows c as powerful language for all types of programming. this type of applications directly interat with hardware. it is one of the example for machine oriented programming.

Article Categories





Give Feedback

Sign up for our email newsletter

Receive updates, enter your email below