Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

unexpected behaviour - sizeof(array).. pls explain..

$
0
0

int array[5]; cout << sizeof(array) // prints 5*sizeof(int) onto the console

but...

int *array = new int[5]; cout << sizeof(array) // prints the same constant number always irrespective of what I enter in
the brackets .... int[ any size ]

What is exactly happening here??? pls somebody help

I figured out this strange behaviour while i was trying to sort a dynamic array using std::sort std::sort(array, array+sizeof(array)/sizeof(array[0]));


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>