Hi
I am declaring an array using new
int *a = NULL;
a = new int[10];
a[0] = 23;
a[1] = 43;
a[2] = 45;
a[3] = 76;
a[4] = 34;
a[5] = 85;
a[6] = 34;
a[7] = 97;
a[8] = 45;
a[9] = 22;
PrintElements(a, 10);
void PrintElements(int * array, int size){
for (int i=0; i<size; i++) {
cout << endl << array[i];
}
}
Now when I print the values I am getting these values
17 2b 2d 4c 22 55 22 61 2d 16
Can somebody tell me what am I doing wrong...? On the other hand when I dont use new & initialize array without it everything works fine.