Here's my main

int main () {
         int list1[3] = {5,5,6}; 
         int num = 3;            
        int result;             
       int *arr = list1;
        int maxVar;              
     int *maxVarHolder;                      
         maxVarHolder = &maxVar;

      
        result = sumarr(*arr, num, *maxVarHolder);
         return 0;
 }

Here's the function header:

int sumarr (int *arr, int size, int *max)

Recommended Answers

All 2 Replies

You want the address of the variables list1 and maxVar to go so your summarr function call be like

result = sumarr(arr, num, maxVarHolder);

The variables arr and maxVarHolder are already pointers to int, using the star * will dereference those into the int variable they point to. The stars are not correct. This will work:

result = sumarr(arr, num, maxVarHolder);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.