What means error: prog.cpp:44:8: error: invalid conversion from ‘int’ to ‘int*’

Write your question here.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    #include<iostream>
    using namespace std;
     
     
    int* pus(int b){
      int top;
      int max;
      max=5;
     
      int* a=new int[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 ‘intint 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



Many thanks!!!
Last edited on
www.cplusplus.com/forum/beginner/125974/
Topic archived. No new replies allowed.