generating array in function po*

Hello!
I am generating array in function, and want it nt to dissapear after function po * scope.

Want to send it to main.
Please, where is the mistake now?
Many thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  int* po(int b){
int d1;
d1=3*b;
int d2;
d2=d1+5;


int a[3];
a[0]=d1;
a[1]=d2;
a[2]=a[1]+3;


int * p;
p=new int[3];
cout<<"po: "<<p<<endl;
return p;
}


int main(){
int st=4;
int z[3];
cout<<" main: "<<po(st)<<endl<<endl<<endl;
cout<<z[1];


return 0;
}


1
2
3
cc1plus: warnings being treated as errors
In function 'int main()':
Line 25: warning: 'z[1]' is used uninitialized in this function
Last edited on
It looks you can write English. Then probably you can read the error message you wrote:


Line 25: warning: 'z[1]' is used uninitialized in this function


Could you find 25-th line in your code? Do you see why z[1] is uninitialized?
Topic archived. No new replies allowed.