In const char *a; and char const *a;both represent the same thing. i.e. the string whose address is store in pointer a is not changeable,but the pointer a can store address of another string if const char *a ="Hello"; /*string is fixed pointer is not*/ then *a='A'; /*Error*/ a="Hi"; /*Work*/
char *const a="Hello"; /*pointer is fixed string is not*/ then *a='A'; /*Work*/ a="Hi"; /*Error*/ On Thu, Jun 7, 2012 at 8:39 AM, shiva@Algo <shiv.jays...@gmail.com> wrote: > const char *a and char const *a are equivalent and 'a' can point to any > variable(even that is not constant) but the thing 'a' points to cannot be > changed and dont need initialisation > > const chat * a;//legal > char c='b';//legal > a=&b;//legal > *a='d';//illegal > c='d';//legal > > but > char * const a --represents a is constatnt pointer that points to a > char.so, It needs an initialisation that will be unchanged for its life > time. > > char c='b'; > char * const a=&c; > *a='d';//legal > char d='e'; > a=&d;//illegal > > > > On Thu, Jun 7, 2012 at 1:22 AM, g4ur4v <gauravyadav1...@gmail.com> wrote: > >> >> 1. const char *a; >> 2. char* const a; >> 3. char const *a; >> >> For each of the above, which operation below is legal and which is >> not? >> >> *a='F' >> a ="Hi" >> >> -- >> 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. >> >> > -- > 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. > -- 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.