Hello,

I have some confusion with Initilization of int.

Qt Code:
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. int *p = new int[4];
  7. for( int i = 0; i < 6568; i++ )
  8. {
  9. p[i] = i;
  10. cout << i << " ->> " << p[i] << endl;
  11. }
  12. return 0;
  13. }
To copy to clipboard, switch view to plain text mode 

Above, i have initilize int *p = new int[4];
when i run this program on windows it get crashed after printing

Output :
0 ->> 0
.
.
.
.
6567 ->> 6567
why is it so ????


And instead of Initilizing like this
int *p = new int[4];

if i initilize
int *p = new int[100];

then on running this example it get crahsed on 182 ?
why is it so ???

Output :
0 ->> 0
.
.
.
.
182 ->> 182
can any body explain me why this happens ?
normally we expect that int[100] will take more values int[4], but its completely different here..!!

can any body tell me what does these below initilization says..!!

int *p = new int();
int *p = new int(10);
int *p = new int[10];

Thanks & Best Regards
Kunal Nandi