C/Visual C - Necesito ayuda con mi programa.

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 15 puestos en C/Visual C (en relación al último mes)
Gráfica de C/Visual C

Necesito ayuda con mi programa.

Publicado por Federico (1 intervención) el 12/02/2021 03:56:46
//HOLA QUE TAL MI NOMBRE ES FEDERICO, ESTOY PREPARANDOME PARA MI PRIMER EXAMEN DE PROGRAMACIÓN EN C LIBRE(YA QUE NO TUVE PROFESOR EN EL AÑO DEBO ESTUDIAR DE MANERA AUTODIDACTA), INTENTO RESOLVER ESTE EJERCICIO PERO ME TRABÉ. LA IDEA ES CREAR UN PROGRAMA QUE EN LA OPCION 1 TOME LOS DATOS DE APUESTA DE UN USUARIO O MAS, Y EN LA OPCION 2 DESPLIEGUE EL TOTAL DE DATOS DE TODOS LOS USUARIOS REGISTRADOS.
LOGRÉ HACER LA LECTURA DE DATOS EN LA OPCION 1 Y MOSTRARLOS EN LA OPCION 2 DEL MENÚ.
LO QUE NO LOGRO ES REGISTRAR MAS DE 1 USUARIO PARA LUEGO MOSTRAR LOS DATOS DE TODOS. (CREO QUE ES CON ALGUN TIPO DE ARRAY CON TOPE O UNA LISTA). PERO NO LOGRO ENCONTRAR ALGUN TUTORIAL QUE ME AYUDE. LA IDEA SERIA PODER INGRESAR CUANTOS USUARIOS DESEE UTILIZANDO LA OPCIÓN 1 PARA LUEGO CON LA OPCIÓN 2 PODER VISUALIZAR TODO LO INGRESADO.

SI PUDIERAN GUIARME CON ESA PARTE LES AGRADECERIA. DESDE A MUCHAS GRACIAS. SALUDOS.

PD: ADJUNTO UNA IMAGEN CON LA CONSIGNA DEL PROGRAMA (POR SI LES INTERESA) Y TAMBIEN UN ZIP CON EL ARCHIVO QUE CREE EN CODEBLOCK.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <stdio.h>
 
#define MAX_LARGO_CEDULA 8
#define MAX_LARGO_NOMBRE 20
#define MAX_CANT_APUESTAS 10000
 
//Estructura guardar fecha
typedef struct{
    int dia;
    int mes;
    int anio;
}Fecha;
 
//Estructura datos apuesta
typedef struct{
    Fecha fechaCarrera;
    int cedApostador[MAX_LARGO_CEDULA];  //EN REALIDAD PEDIA CHAR!!!
    char nomCaballo[MAX_LARGO_NOMBRE];
    int monto;
}Apostador;
 
void cargarApuesta(Apostador vec[MAX_CANT_APUESTAS], int n){
 
        int i;
        printf("\nAlta de Apuesta:");
 
        for(int i=0; i<n; i++){
 
 
        printf("\nIngrese la fecha de la apuesta con formato dia/mes/anio: ");
        scanf("%d/%d/%d", &vec[i].fechaCarrera.dia, &vec[i].fechaCarrera.mes, &vec[i].fechaCarrera.anio);
        printf("Ingrese la cedula del apostador: ");
        fflush(stdin);
        scanf("%d", &vec[i].cedApostador);          //EN REALIDAD PEDIA CHAR!!!
        fflush(stdin);
        printf("Ingrese el nombre del caballo: ");
        fflush(stdin);
        gets(vec[i].nomCaballo);
        fflush(stdin);
        printf("Ingrese el monto que desea apostar: ");
        fflush(stdin);
        scanf("%d", &vec[i].monto);
        }
}
 
void listarApuesta(Apostador vec[MAX_CANT_APUESTAS], int n){
    int i;
    printf("Lista de Apuestas:\n");
 
    for(int i=0; i<n; i++){
 
        printf("\nFecha de la apuesta: %d/%d/%d/", vec[i].fechaCarrera.dia, vec[i].fechaCarrera.mes, vec[i].fechaCarrera.anio);
        printf("\nCedula del apostador: %d", vec[i].cedApostador);
        printf("\nNombre del caballo: %s", vec[i].nomCaballo);
        printf("\nMonto apostado: %d", vec[i].monto);
    }
}
 
 
int main(){
 
    int n=1;
 
    int opcion;
 
    do{
        printf("\t***Bienvenido al centro de apuestas HIDALGO***");
        printf("\n1. Alta de apuestas");
        printf("\n2. Lista de apuestas");
        printf("\n0. Salir");
        scanf("\n%d", &opcion);
 
        Apostador apostadores[MAX_CANT_APUESTAS];
 
 
        switch(opcion){
 
            case 1: cargarApuesta(apostadores, n);
            break;
            case 2: listarApuesta(apostadores, n);
            break;
            default:printf("Seleccione una opcion valida");
        }
    }while(opcion!=0);
 
    Apostador apostadores[MAX_CANT_APUESTAS];
 
    cargarApuesta(apostadores, n);
 
    listarApuesta(apostadores, n);
 
 
    return 0;
}

Screenshot_1
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 89
Ha mantenido su posición en C/Visual C (en relación al último mes)
Gráfica de C/Visual C

Necesito ayuda con mi programa.

Publicado por Bruno (38 intervenciones) el 03/03/2021 20:50:24
El problema es que a la función cargarApuesta toma como segundo argumento el valor a cargar y siempre le envías 1.
Me tomé el tiempo de hacer algo de código y te lo dejo adjunto.
Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar