C++ passing dynamic array element to a function
The code looks like this:
void fUnc(float a){
//does nothing
}
int main(){
float* a = new float[3];
// Initialization of a comes here
fUnc(a[0]);
printf("%f, %f, %f", a[0], a[1], a[2]);
return 0;
}
Values of array elements are -107374176.000000. Everything works well if
fUnc(a[0]) [which does nothing] is commented out. What's the problem?
No comments:
Post a Comment