What is the difference between const int *ptr and int const
*ptr???

Answers were Sorted based on User's Feedback



What is the difference between const int *ptr and int const *ptr???..

Answer / manjunath

a) const int *ptr and
b) int const *ptr


Both actually mean the same...

Read from Right to left:
for(a):-> ptr is a pointer to an integer Constant and
for(b):-> ptr is a pointer to a constant integer...

..............
int *const ptr----------> ptr is a constant pointer to an
integer...

Is This Answer Correct ?    95 Yes 26 No

What is the difference between const int *ptr and int const *ptr???..

Answer / abdul sami

'const int* ptr' means the value whose address is being
held by ptr is constant and cant be changed while
'int const *ptr' means the pointer cant be changed like it
cant be incremented or decremented although you can change
the date pointed to by ptr.

Is This Answer Correct ?    41 Yes 57 No

Post New Answer

More OOPS Interview Questions

what's the basic's in dot net

0 Answers   informatics,


What is the difference between and interface and an abstract class ?

4 Answers   IBM, Infosys, Ness Technologies,


sir i want to know which posting to apply since i am BE CSE.. also want to know what are the rounds there for my interview...Expecting for ur valuable answer....

2 Answers  


how many types of notations are in java

1 Answers   National University of Modern Languages (NUML),


what is overloading

3 Answers   MindCracker,


What is the difference between an object and a class?

3 Answers  


#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

0 Answers  


Why do we need oop?

0 Answers  


Why static functions always uses static variables?

3 Answers  


what is data hiding.

3 Answers   Wipro,


how to find no of instances of an object in .NET?

1 Answers   Infosys,


How would you stop a class from class from being derived or inherited.

18 Answers   Ness Technologies,


Categories