How did a structure go to a function, C ++?

0

They ask me to do a program that reads, name , code , and 3 notes , everything is 10 students; in a structured vector called vec_est , my problem is when sending the structure to the function.

include stdio.h
include stdlib.h
include string.h
include conio.h


struct vec_est
{
    char nombre[10];
    int codigo;
    float notas[3];

}vecest[2];

int fun_promedio(struct vec_est);

main()
{
    const int est =2;
    const int no = 3;
    int i=0,j=0;
    float promedios[3];

    for(i=0;i<est;i++)
    {
        printf("ingrese el nombre[%d]\n",i);
        scanf("[^\n]",&vecest[i].nombre);
        fflush(stdin);
        printf("ingrese el codigo de estudiante [%d]",i);
        scanf("%d",& vecest[i].codigo);
        fflush(stdin);
        printf("ingrese 3 notas\n");
        for(j=0;j<no;j++)
        {
            scanf("%d",&vecest[i].notas[j]);
            fflush(stdin);
        }
    }
     fun_promedio( vec_est); // aqui es que me da el error al conectar la funcion// . 
}

int fun_promedio(struct vec_est)
{
    int j=0,i=0;
    for(i=0;i<2;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("el valor es de %d\n",vecest[i].notas[j]);
        }
    }
}
    
asked by Joseph Saucedo 26.06.2018 в 22:43
source

1 answer

0

If what you need is that the function receives an array you must declare the parameter as such:

int fun_promedio(struct vec_est []);
//                              ^^
    
answered by 06.07.2018 в 07:28