Codigo
Programa que al ingresar el Precio Inicial y el Precio Final de un Artículo,
imprime el porcentaje de descuento y lo almacena en un archivos de datos.
Eleazar Vicente Ruelas Vázquez -1614633*/
#include
#include
#include
typedef struct {
char Articulo[30];
float PrecioInicial, PrecioFinal;
}regPrecios;
regPrecios vtrPrecios;
FILE*ptfPrecios;
typedef struct {
char Articulo[30];
float PrecioInicial, PrecioFinal;
float Descuento;
}regDescuento;
regDescuento vtrDescuento;
FILE *ptfDescuento;
int n;
char Articulos[100][30];
voidIngresaDatos(regPrecios vtrPrecios);
void DatosArreglo(regPrecios vtrPrecios);
void ImprimeArreglo(float Pi[], float Pf[], float P[], int n);
void ArregloArchivo(float Pi[], float Pf[], float P[], intn, regDescuento vtrDescuento);
void Encabezado();
void ImprimeArchivo();
void gotoxy(short x, short y){
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}int main(){
int linea;
IngresaDatos( vtrPrecios );
DatosArreglo( vtrPrecios );
system( "pause\n" );
system( "cls" );
ImprimeArchivo();
system( "pause\n" );
}
voidIngresaDatos( regPrecios vtrPrecios ){
char opcion[2];
ptfPrecios = fopen("precios.dat","w");
do{
system("cls");
printf("\n Nombre del Articulo: ");
scanf("%[^\n]",vtrPrecios.Articulo);
printf(" Precio Inicial: ");
scanf("%f",&vtrPrecios.PrecioInicial);
printf(" Precio Final: ");
scanf("%f",&vtrPrecios.PrecioFinal);fwrite(&vtrPrecios, sizeof(regPrecios), 1, ptfPrecios);
strset(vtrPrecios.Articulo,' ');
printf("\n Agregar mas articulos?[s/n]: ");
scanf(" %[^\n]",opcion);
}while(!strcmp(opcion,"S") ||!strcmp(opcion,"s"));
fclose(ptfPrecios);
}
void DatosArreglo( regPrecios vtrPrecios ){
int i = 1, N;
float Pi[100], Pf[100], D[100];
ptfPrecios = fopen("precios.dat","r");
fread(...
Regístrate para leer el documento completo.