Doubt of passage of vector of structures to a function in C

0

I get the following error when wanting to pass the vector to a function:

  

[Error] could not convert '(teachers *) (& prfsr)' from 'professors *' to 'professors'.

I pass the code to see what's wrong, I've been trying for a while to solve it, even pass it with pointers and even then it keeps giving me an error, thanks in advance for the help.

#include<stdio.h>
#include<stdlib.h>

struct profesores{
    char nombre[30];
    char sexo[30];
    int edad;

};

void promed(profesores,int);
void joven(profesores, int);
int menu();
int main(){

profesores prfsr[100];
int n,opcion;
float promedio;
printf("-------BIENVENIDO AL REGISTRO DE LOS PROFESORES-------\n");
    printf("Cuantos profesores desea registrar?\n");
            scanf("%d",&n);

                for(int i=0;i<n;i++){
                    printf("Introduzca el nombre\n");
                        fflush(stdin);
                            gets(prfsr[i].nombre);
                            printf("Introduzca el genero\n");
                                fflush(stdin);
                                    gets(prfsr[i].sexo);    
                                        printf("Introduzca la edad\n");
                                            scanf("%d",&prfsr[i].edad);
                                            system("cls");  

                                            if(i==n-1){
                                                printf("Profesores Registrados Exitosamente\n");

                                            }



                }       
            promed(prfsr,n);
                opcion=menu();

                        switch(opcion){
                            case 1: 
                                    break;




                        }


}
int menu(){
 int opcion;
    printf("Seleccione una opcion\n");
    printf("1....Nombre del profesor mas joven del registro\n");
    printf("2....Nombre del profesor con mas edad\n");
    printf("3....No. de Profesores con edad mayor al promedio\n");
    printf("4....No. de Profesores con edad menor al promedio\n");
    scanf("%d",&opcion);
    return opcion;  
}
void joven(profesores registro[],int n){

    for(int i=0;i<n;i++){
        registro[i].edad;

    }


}
void promed(profesores promedio[],int n){
float prom=0;
int suma; 
for(int i=0;i<n;i++){

    suma=suma+promedio[i].edad; 
}   

prom= suma/n;

}
    
asked by Jose Ivan Chavez 10.06.2018 в 06:07
source

1 answer

0

You have this wrong

void promed(profesores,int);
void joven(profesores, int);

You should put it like that

void promed(profesores*,int);
void joven(profesores*, int);

And the functions declare them in one of these two ways if it is in C

void promed(struct profesores *p,int i)
{
 ///código
}
void joven(struct profesores p[],int i)
{
 ///código
}

And if it's in C ++ you can also do it like that

void promed(profesores *p,int i)
{
 ///código
}
void joven(profesores p[],int i)
{
 ///código
}
    
answered by 10.06.2018 в 08:46