#include<iostream>
usingnamespace std;
int* pus(int b){
int top;
int max;
max=5;
int* a=newint[5];
srand(time(0));
int number;
for(int i=0;i<top;i++){
number=rand()%10;
a[top]=number;
}
return a;
}
int* po(int arraypo[5], int g){
for(int i=5;i>=0;i++){
arraypo[i]=0;
}
return arraypo;
}
int main(){
int st=5;
int * z;
z=pus(st);
cout<<"main: "<<pus(st)<<endl;
cout<<z[0]<<" "<<z[1]<<" "<<z[2]<<" "<<z[3]<<" "<<z[4]<<" "<<endl;
cout<<&z[0]<<" "<<&z[1]<<" "<<&z[2]<<endl;
int arraypo[5]=int z[5];
z=po(st);
cout<<z[0]<<" "<<z[1]<<" "<<z[2]<<" "<<z[3]<<" "<<z[4]<<" "<<endl;
delete z;
cout<<z[4]<<endl<<z[0]<<endl;
return 0;
}
Compilation error
comments (0)
stdin
copy
Standard input is empty
compilation info
prog.cpp: In function ‘int* pus(int)’:
prog.cpp:7:9: warning: variable ‘max’ set but not used [-Wunused-but-set-variable]
int max;
^
prog.cpp: In function ‘int main()’:
prog.cpp:43:16: error: expected primary-expression before ‘int’
int arraypo[5]=int z[5];
^
prog.cpp:44:8: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
z=po(st);
^
prog.cpp:44:8: error: too few arguments to function ‘int* po(int*, int)’
prog.cpp:23:6: note: declared here
int* po(int arraypo[5], int g){
^
prog.cpp:43:5: warning: unused variable ‘arraypo’ [-Wunused-variable]
int arraypo[5]=int z[5];
^
stdout
Standard output is empty