How can I modify data a record with pointers in C? [closed]

1

In my program I have a struct students record where I input data from 3 students, ( name, age, phone ), into the program main ( main ) asks what you want to do, when selecting the option "modify", I need to modify some value entered, but in a function apart, there are 3 functions in total and I only came to complete one

    #include <stdio.h>
    #define n 3


    struct alumno{

        char nombre[20];
        int edad;
        int telefono;
    }alum[n];

    int main(){

        int opcion,i;
        struct alumno*punt;
        punt=alum;

        for(i=0;i<n;i++){
            printf("alumno; %d",i+1);
            printf("\n");
            printf("ingrese nombre ");
            scanf("%s",(punt+i)->nombre);
            printf("ingrese edad ");
            scanf("%d",&(punt+i)->edad);
            printf("ingrese telefono ");
            scanf("%d",&(punt+i)->telefono);
        }
        printf("1_dar de alta 2_modificar registro 3_buscar el alumno mayor");
        scanf("%d",&opcion);

        switch(opcion){

            case 1: alta(punt);
                    break;
            case 2: modificar(punt);
                    break;
            case 3:mayor(punt);
                    break;
        }  
    }

    void alta(struct alumno *p){

        int i,j;
        for(i=0;i<n;i++){
            if(strcmp((p+i)->nombre,"")==0){
                printf("nombre : ");
                scanf("%s",(p+i)->nombre);
                printf("edad : ");
                scanf("%d",(p+i)->edad);
                printf("telefono : ");
                scanf("%d",&(p+i)->telefono);
            }
}
    
asked by user74897 09.02.2018 в 21:47
source

0 answers