Re: [algogeeks] Re: Differentiate the following declarations.

2012-06-12 Thread Mad Coder
*const char* a* is *equivalent* to *char const * a*

A simple method which most people use in coding is that const is written
after the value which needs to be constant.
So,
*char const *a* means a is a pointer that points to a character which is a
constant i.e you can not change the value which a points to, however you
can change values for a i.e different addresses can be applied to a.
and
*char *const a*  means a is a constant pointer to character i.e you can
change the values pointed by a, however you can not change the values i a
i.e once a is assigned an address, a can not be changed.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Differentiate the following declarations.

2012-06-08 Thread Navin Gupta
Using Spiral-Anderson rule, 
1:- const char * a - a is a pointer to char const (character which is 
constant , the value pointed by the pointer is constant)
2:- char * const a - a is a const pointer to char (pointer is constant, it 
always point to same memory location)
3:- char const * a - a is a pointer to const char (again character is 
constant , the value pointed by the pointer is constant)

*a='F' 
a =Hi 

From above 
 1  2  3
*a= 'F'   Legal  Illegal  Legal
a=Hi   Illegal Legal   Illegal

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/AKf8Zszo-IoJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.