This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

function point

flowing is error,Please help me!!

#include <stdio.h>
#define NUMBER 2


int max(int a[])
{
int z;
if(a[0]>a[1]) z=a[0]; else z=a[1];
return(z);
}



int process(void (* fun)(void *p),void *arg)
{
int z;
z=(int *)(* fun)((int *)arg);
return(z);
}



main()
{
int a[NUMBER];
int i;
int d;
for(i=0;i++;i<NUMBER) a[i]=i;

d=process(max,a);
while(1);
}

Parents
  • #include <stdio.h>
    #define NUMBER 2
    
    int max(int a[])
    {
        int z;
        if(a[0]>a[1]) z=a[0]; else z=a[1];
        return(z);
    }
    
    int process(void (* fun)(void *p),void *arg)
    {
        int z;
        z=(int *)(* fun)((int *)arg);
    In the line above, the usage does not match the declaration.
        return(z);
    }
    
    main()
    {
        int a[NUMBER];
        int i;
        int d;
        for(i=0;i++;i<NUMBER) a[i]=i;
    The loop will never be entered. It appears you have the loop termination expression and the loop iteration expression reversed.
        d=process(max,a);
    The first argument has a type mismatch, implicitly attempting to convert an int (*)(int *) to a void (*)(void *)
        while(1);
    }

Reply
  • #include <stdio.h>
    #define NUMBER 2
    
    int max(int a[])
    {
        int z;
        if(a[0]>a[1]) z=a[0]; else z=a[1];
        return(z);
    }
    
    int process(void (* fun)(void *p),void *arg)
    {
        int z;
        z=(int *)(* fun)((int *)arg);
    In the line above, the usage does not match the declaration.
        return(z);
    }
    
    main()
    {
        int a[NUMBER];
        int i;
        int d;
        for(i=0;i++;i<NUMBER) a[i]=i;
    The loop will never be entered. It appears you have the loop termination expression and the loop iteration expression reversed.
        d=process(max,a);
    The first argument has a type mismatch, implicitly attempting to convert an int (*)(int *) to a void (*)(void *)
        while(1);
    }

Children