wats the diference btwen constant pointer and pointer to a
constant.pls give examples.
Answer Posted / satyajit nayak
Hello All,
AS name suggested things are very simple.
1.Constant pointer
======================
it's nothing but a
(i)pointer which is pointing to a constant memory
location.
(ii)Once this pointer is assigned to point some location
we cann't make it to locate some other address location.
(iii)So constant pointer should be initialized at the
point of declaration only.
Example
=========
1. int main()
{
int * const my_ptr; //now my_ptr point to garbage
location
int var=10;
my_ptr=&var; //trying to modify my_ptr location.so
gives ERROR
}
so correct way of assignment is like
int main()
{
int var=10;
int * const my_ptr=&var;
printf("Addr=%x,val=%d",my_ptr,*my_ptr);
}
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is actual argument?
What is the difference between text and binary i/o?
how should functions be apportioned among source files?
Is there any data type in c with variable size?
Define Array of pointers.
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
What do you mean by dynamic memory allocation in c? What functions are used?
What is a loop?
What is structure padding and packing in c?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
What does the message "automatic aggregate intialization is an ansi feature" mean?
How do you determine whether to use a stream function or a low-level function?
Explain how many levels deep can include files be nested?
What is else if ladder?
Write programs for String Reversal & Palindrome check