|
|
|||||||
| Home Page |
|||||||
Effetive Use of PointersAbstact : 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
Rate this Article:
Current: 0 / 5 stars - 0 vote(s).
Article Tags: Pointers, Pointers In C, Saving Memory Using Pointers Article Source: http://www.articlesbase.com/programming-articles/effetive-use-of-pointers-580449.html About the Author:
pointers in c - yashwant kanitkar
Related ArticlesDirect Mail Sales Letters Flow Better With Subheads How to find the perfect home business? Learn to Play the Piano the Easy Way Small Game Hunting and your Safety in the Wilderness 10 Pointers for Navigating With your Vehicle in Ice and Snow 10 More Pointers for Navigating your Vehicle in Ice and Snow More Pointers for Driving a Vehicle in Ice and Snow: Tires Making the Most of your Credit Card 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? Save as glitch on windows vista Vista 'save as' glitch I recived e=mail for (microsoft lottey) do you ... How to Install .Net framework 3.5 on Microsoft ... How can i setup my email account with microsoft ... Latest Programming ArticlesCool Desktop Wallpapers Tips for Buying Software Online Mvc Design Pattern Advantages of Low Cost Contract Programmers in Freelance Programming A Guide to Cnc Kits A Guide to Cnc Tube Bending Machines Ways to Hire Dedicated Php Programmers Top 4 Reasons Why Addressing Web Accessibility is Important More from varadarajan tBitlevel Operations in C |
|||||||
|
Article Categories
|
|||||||
|
|
|||||||