I have the following function:
int *array1=new int [3];
void My_function()
{
My_set(array1);
for(int i=0;i<3;i++){ //The output is 5 15 55
cout<<array1[i]<<endl;
}
Display (array1)
}
void My_set(int *array1)
{
array1[0]=5;
array1[1]=15;
array1[2]=55;
}
void Display(int *array1){
for(int i=0;i<3;i++){
cout<<array1[i]<<endl; //The output is Garbage -842150451
}
}
Note: This problem occurred in complex project but I show my problem in simple code ! THANK YOU :)