-1

I want to create an integer array that can hold 8 bytes of data, I have used this code

int n =50; 
long long *buffer = new long  long [n];

the size of long long is 8 bytes but

sizeof(buffer) 

only gives 4 bytes is it that the heap doesn't allow more than 4 bytes allocation? there is something that I have missed here but don't know what it is.

Skeptical Ant
  • 384
  • 5
  • 19

1 Answers1

3

sizeof (x) gives the number of bytes consumed by x. In your case x is the pointer to the allocation. If the allocation succeeds, you know that it allocated the requested size (or possibly a little more).

wallyk
  • 56,922
  • 16
  • 83
  • 148