See more articles about "C Language Programming "

Pointers



 31 December 18:00   

    

What is a Pointer?

    

Each anamnesis area that we use to abundance the data hase an abode in computre

    

anamnesis (RAM). Computer Accouterments i.e. CPU uses this addess to advertence to a

    

accurate data item. A arrow is a capricious that food the abode of addition

    

variable.



    

A arrow is a capricious that represents the area of a data item, such as

    

a capricious or an arrangement element. Pointers are acclimated frequently in C, as they accept

    

a amount of advantageous applications. For example, pointers can be acclimated to canyon advice

    

aback and alternating amid a action and its advertence point. Pointers accommodate

    

a way to acknowledgment assorted data items from a action via action arguments to

    

be defined as arguments to a accustomed function.



    

Pointers are aswell carefully associated with arrays and accordingly accommodate an alternating way to admission alone arrangement elements.



    

Within the computers memory, every stored data account occupies one or added adjoining

    

anamnesis cells. The amount of anamnesis beef appropriate to abundance a data account depends

    

on the blazon of data item. For example, a individual appearance will be stored in

    

1 byte of anamnesis accumulation usually requires two adjoining bytes, a amphibian point

    

amount may crave four adjoining bytes.



    

Declaring a Pointer

    

A arrow is declared just like we acknowledge a variable. There is alone one aberration

    

in acknowledgment is that we add an asterisk * infront of it to announce that it s

    

a capricious which is a pointer. For example



    

int* i;

    

long* y;



    

you can aswell acknowledge the pointers as



    

int *i;

    

long *y;



    

How Arrow work?

    

Lets address an archetype to authenticate the use of pointers.

    

int num = 10;

    

int *pnum;

    

pnum = #



    

Now pnum will be accepting the abode of the num variable.

    

Initializing pointers

    

It is generally a acceptable practise to intialize the capricious while declaring. It is

    

actual simple to initialize a arrow to the abode of a capricious that has already

    

been defined.

    

int num=10;

    

int* pnum= #



    

You can aswell initialize the arrow to the absence absent value.

    

int* pnum = NULL;


    

Here is a simple archetype that demonstrates the altered aspects of the arrow

    

operations.

    

#include <stdio.h>

    

int main(void){

    

int num=10;

    

int* pnum=NULL;

    

pnum = &num;

    

*pnum += 20;

    

printf("
Number = %d", num);

    

printf("
Pointer Amount = %d", *pnum);

    

return 0;

    

}



    

Discuss this tutorial here



    



    

Forum: Pointers (Total 3 Messages)


 


 pointers, variable, pointer, memory, function, example, address, *pnum, adjacent, , data item, int* pnum, & num, int num, variable that, pnum &, int* pnum null,

Share Pointers: Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

UNIONS :: Unions & Structures
PUNIONS /PPUnions, like anatomy accommodate members, whose alone data types may vary. These is above acumen amid them in agreement of accumulator .In structures anniversary affiliate has its own accumulator location, area as all the associates of a abutment use the afor

Pointers
What is a Pointer?/h2PEach anamnesis area that we use to abundance the data hase an abode in computre anamnesis (RAM). Computer Accouterments i.e. CPU uses this addess to advertence to a accurate data item. A arrow is a capricious that food the abode of additio

Comparing Two Stuctures :: Unions & Structures
PComparing Two Stuctures/FONT/PPYou can use memcmp(). See man memcmp for added details. If your anatomy has pointers, then move them to the end and do not analyze anamnesis breadth for the pointer. You accept to analyze pointers explicitly.

Book Administration in C Accent
PIn this section, we will altercate about files which are actual important for all embracing data processing. Data are stored in data files and programs are stored in program files. /Ph1What is a File?/h1PAbstractly, a book is a accumulating of byt

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

Loops & Accommodation Ascendancy Anatomy
We charge a apparatus to analyze things to yield any decision. This involves using some operatios calles strongRelational Operators. /strongWe accept axiological operators to analyze two values. ol strong</strong Beneath thanp

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

What Is a Stream? :: Ascribe & Achievement
PA beck is a arrangement of characters. Added exactly, it is a arrangement of bytes of data. A arrangement of bytes abounding into a program is an ascribe stream; a arrangement of bytes abounding out of a program is an achievement stream. By absorption on streams

Book Administration in C Accent
PIn this section, we will altercate about files which are actual important for all embracing data processing. Data are stored in data files and programs are stored in program files. /Ph1What is a File?/h1PAbstractly, a book is a accumulating of byt