News:

Build a stunning handcrafted website with IT Acumens

Main Menu

Character Pointer

Started by thiruvasagamani, Sep 22, 2008, 10:31 AM

Previous topic - Next topic

thiruvasagamani

Character pointer:

char ch = 'g';
char * p;
p = & ch; or char * p = & ch;
From the above, address of variable 'ch' is stored in pointer 'p', 'p' is a pointer to variable 'ch', 'p' is having address of variable 'ch' and then * p is value that is character 'g'.

NOTE:

    * * is value when 'p' points to number i.e, *p is value
    * * is character when 'p' points to character i.e, *p is char


float m= 10.98;
float *p = &m;
sizeof( p ) = 2 bytes ( in turbo c compiler)
sizeof( *p) = 4 bytes ( in turbo c compiler)
'p' is a pointer hence 2 bytes , * p is value( float value) hence 4 bytes


Thiruvasakamani Karnan