wats the diference btwen constant pointer and pointer to a
constant.pls give examples.

Answer Posted / rudra prasad panda

Pointer is a variable containing the addres of another
variable;
Constant pointer is a variable which points to a variable
constantly.it means that , once it is initialised,it cannot
be changed.Till the end of program,it points to that
variable only;
EXAMPLE:
char k,m;
const char *p=&k;
p=&m;//(syntax error)

********
A pointer to a constant is a pointer such that the contents
of the variable(pointed by the pointer)cannot be modified
throuhg the pointer;
EXAMPLE:
char m='l';
char * const p;
p=&m;
*p='u';//syntax error
m='k';//no syntax error

Is This Answer Correct ?    8 Yes 42 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is #line used for?

603


Explain void pointer?

587


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

724


What are the different types of linkage exist in c?

611


What language is c written?

574






What are the parts of c program?

627


What are the functions to open and close file in c language?

723


Write the Program to reverse a string using pointers.

613


What are qualifiers and modifiers c?

543


Not all reserved words are written in lowercase. TRUE or FALSE?

719


What is the use of getchar() function?

624


What is p in text message?

536


Why does the call char scanf work?

613


what is stack , heap ,code segment,and data segment

2214


what is the syallabus of computer science students in group- 1?

1836