What is a const pointer, and how does it differ from a pointer to a const?

Answers were Sorted based on User's Feedback



What is a const pointer, and how does it differ from a pointer to a const?..

Answer / nashiinformaticssolutions

1. Pointer to const: The value being pointed to cannot be modified, but the pointer itself can change.
Example:
2. const int a = 10;
3. const int *ptr = &a; // *ptr is read-only
4. const pointer: The pointer cannot change, but the value it points to can.

Is This Answer Correct ?    0 Yes 0 No

What is a const pointer, and how does it differ from a pointer to a const?..

Answer / glibwaresoftsolutions

1. Pointer to const: The value being pointed to cannot be modified, but the pointer itself can change.
Example:
2. const int a = 10;
3. const int *ptr = &a; // *ptr is read-only
4. const pointer: The pointer cannot change, but the value it points to can.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Explain what are the different file extensions involved when programming in c?

0 Answers  


How many keywords are there in c?

0 Answers  


write a program to swap Two numbers without using temp variable.

75 Answers   EMC, Focus, GreyB, HCL, Hitech, HP, Huawei, Infosys, Mannar Company, Microsoft, Miles Software, Odessa Technologies, Satyam, TCS, Wipro,


How to add two numbers with using function?

4 Answers  


What is the difference between mpi and openmp?

0 Answers  


plz answer..... a program that reads non-negative integer and computes and prints its factorial

2 Answers  


How many main () function we can have in a project?

0 Answers  


Which of the following data structures is on average the fastest for retrieving data: 1) Binary Tree 2) Hash Table 3) Stack

3 Answers  


What is the difference between calloc() and realloc()?

1 Answers  


Differentiate between Macro and ordinary definition.

0 Answers   Motorola,


Write a program to print distinct words in an input along with their count in input in decreasing order of their count

0 Answers  


what is differnence b/w macro & functions

1 Answers  


Categories