I'm new to C programming and just doing homework, thing is, I cant figure out why this the choice "Visualizar platos del dia" outputs weird symbols and not the things that I've input in with the cargar structure.
#include <stdio.h>
#include <string.h>
#include <strings.h>
struct platos{
char aperitivo[40];
char plato1[40];
char plato2[40];
char postre[40];
char bebida1[40];
char bebida2[40];
char bebida3[40];
};
void cargar(struct platos a);
void vis(struct platos a);
void emit(struct platos a);
int main(){
int a=0, b=0;
struct platos plato;
do{
printf("Bienvenido a restaurante 'Senior bigotes'\n\n");
printf("1:Cargar platos del dia\n");
printf("2:VIsualizar platos del dia\n");
printf("3:Emitir comanda y factura\n");
printf("4:Salir\n");
scanf("%d", &a);
switch(a){
case 1: cargar(plato);
break;
case 2: vis(plato);
break;
case 3: emit(plato);
break;
case 4:
b++;
break;
}
}while(b<1);
return 0;
}
void cargar(struct platos a){
printf("Ingrese aperitivo\n");
__fpurge(stdin);
gets(a.aperitivo);
printf("Ingrese plato 1\n");
__fpurge(stdin);
gets(a.plato1);
printf("Ingrese plato 2\n");
__fpurge(stdin);
gets(a.plato2);
printf("Ingrese postre\n");
__fpurge(stdin);
gets(a.postre);
printf("Ingrese bebida 1\n");
__fpurge(stdin);
gets(a.bebida1);
printf("Ingrese bebida 2\n");
__fpurge(stdin);
gets(a.bebida2);
printf("Ingrese bebida 2\n");
__fpurge(stdin);
gets(a.bebida3);
}
void vis(struct platos a){
printf("\nAperitivo: %s", a.aperitivo);
printf("\nPlato 1: %s", a.plato1);
printf("\nPlato 2: %s", a.plato2);
printf("\nPostre: %s", a.postre);
printf("\nBebidas: %s | %s | %s\n", a.bebida1, a.bebida2, a.bebida3);
int c = getchar();
}
void emit(struct platos a){
printf("\nAperitivo: %s $10", a.aperitivo);
printf("\nPlato 1: %s $25", a.plato1);
printf("\nPlato 2: %s $35", a.plato2);
printf("\nPostre: %s $20", a.postre);
printf("\nBebidas: %s | %s | %s $15\n", a.bebida1, a.bebida2, a.bebida3);
printf("Total: $105");
int c = getchar();
}
I'm using manjaro btw with visual code. I asked the teacher and he wants me to debug the code but Idk how to do that in visual code. Any help?