Code:
#include <stdio.h>
#include <conio.h>
struct cliente
{
char cliente[30];
};
struct cliente dato[30];
struct vendedor
{
char ne[30];
};
struct vendedor dato2[30];
struct producto
{
char np[30];
float pp;
int cp;
};
struct producto dato3[30];
struct tienda
{
char nt[30],fecha[20];
};
struct tienda dato4[30];
void leer(int);
void mostrar(int);
void main()
{
int i;
clrscr();
printf("\nCuantos clientes desea evaluar:");
scanf("%d",&i);
leer(i);
mostrar(i);
getch();
}
void leer(int i)
{
int j;
clrscr();
for(j=0;j<i;j++)
{
printf("Ingrese nombre de la tienda: ");
scanf(" %[^\n]",dato4[j].nt);
printf("\nIngrese fecha actual: ");
scanf(" %[^\n]",dato4[j].fecha);
printf("\nIngrese nombre del cliente: ");
scanf(" %[^\n]",dato[j].cliente);
printf("\nIngrese nombre del vendedor: ");
scanf(" %[^\n]",dato2[j].ne);
printf("\nIngrese el nombre del producto: ");
scanf(" %[^\n]",dato3[j].np);
printf("\nIngrese la cantidad que se compro de dicho producto: ");
scanf("%d",&dato3[j].cp);
printf("\nIngrese el precio unitario del producto: ");
scanf("%f",&dato3[j].pp);
clrscr();
}
}
void mostrar(int i)
{
float st,stt,t;
int j;
clrscr();
for(j=0;j<i;j++)
{
st=(dato3[j].cp*dato3[j].pp);
stt=(0.15*st);
t=(st+stt);
printf("\n\t\t\t\tTienda %s",dato4[j].nt);
printf("\t\t\t%s",dato4[j].fecha);
printf("\n\nCliente %s",dato[j].cliente);
printf("\nVendedor %s",dato2[j].ne);
printf("\n\nProducto %s",dato3[j].np);
printf("\nCantidad de Producto: %d",dato3[j].cp);
printf("\nPrecio Producto: %.2f",dato3[j].pp);
printf("\n\nSub-Total: %.2f",st);
printf("\nIVA: 15 Porciente");
printf("\n\nTotal: %.2f",t);
}
}
First and formost i apologize the program is mostly in spanish im not from the US but from latinamerica Secondly yes my code is prob sloppy and sux but anywho down to my problem.
Ok what the program does is preety much a receipt from a store,so it askes how many clients we want to do receipts for,then asks the name of the client,vendor name,product name,quantity of said product and its price,oh and store name and date.
Ok so my problem is the follow,when i compile it,doesnt give me any errors but when it gets to:
Code:
printf("\nIngrese la cantidad que se compro de dicho producto: ");
scanf("%d",&dato3[j].cp);
Meaning when on the screen appears "Ingrese la cantidad que se compro de dicho producto" (Insert quantity bought of said product),ok i input a integer number lets say 3,i press enter and it exits the program I have no idea what the problem is,any help is great appreciated.Thank you in advance for your help.