Pointers in C++

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
Hi,

int *p = (int*)malloc(sizeof(int)*1);
p[0]=2;
p[1]=3;

I allocated memory for only one item but I am able to assign value to second item? How it is possible? How to restrict it?

Continue reading...
 
Back
Top