Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im not passing something in the argument but im not sure what it is error \"too

ID: 3684198 • Letter: I

Question

Im not passing something in the argument but im not sure what it is

error "too few arguments to function "

C programming

///call function

find_product(products,char *name);

//function

void find_product(struct Product products[],int n,char *name)
{
        int i;

        for(i=0;i<n;++i)
        {
                if(strcmp(products[i].name,name)==0)
                {
                        printf("Name: %s ",products[i].name);
                        printf("Price: %.2lf ",products[i].price);
                        printf("Number of pounds sold: %.2lf ",products[i].total);
                        printf("Sales volume: %.2lf ",products[i].sale_vol);
                }
        }
}

Explanation / Answer

///call function

void find_product(struct Product[], int ,char*); ->function declaration. Put this before main

find_product(product, n, name) ->use this to call function, you were missing n

//function Put this after main

void find_product(struct Product products[],int n,char *name)
{
        int i;

        for(i=0;i<n;++i)
        {
                if(strcmp(products[i].name,name)==0)
                {
                        printf("Name: %s ",products[i].name);
                        printf("Price: %.2lf ",products[i].price);
                        printf("Number of pounds sold: %.2lf ",products[i].total);
                        printf("Sales volume: %.2lf ",products[i].sale_vol);
                }
        }
}