Gracias por su ayuda a todos ya que me han resuelto varias dudas con eso creo que puedo seguir, ahora me dedicare a la tarea de terminar el codigo.
Les agradezco su ayuda
![;-) ;-)](https://forum.elhacker.net/Smileys/navidad/aplaudir.gif)
Saludos
Les agradezco su ayuda
![;-) ;-)](https://forum.elhacker.net/Smileys/navidad/aplaudir.gif)
![;-) ;-)](https://forum.elhacker.net/Smileys/navidad/aplaudir.gif)
![;-) ;-)](https://forum.elhacker.net/Smileys/navidad/aplaudir.gif)
Saludos
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúvoid grabar_fichero (){
int f,c;
bodega = fopen("price1.dat", "wb");
if (bodega == NULL){
printf ("\nERROR: No se ha podido abrir el archivo pricemat ");
system("pause");
exit(0);
}
else{
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.blanco[f][c], sizeof(pricemart.blanco), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.amarillo[f][c], sizeof(pricemart.amarillo), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.negro[f][c], sizeof(pricemart.negro), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.rojo[f][c], sizeof(pricemart.rojo), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.plata[f][c], sizeof(pricemart.plata), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.verde[f][c], sizeof(pricemart.verde), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.lila[f][c], sizeof(pricemart.lila), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.cafe[f][c], sizeof(pricemart.cafe), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.naranja[f][c], sizeof(pricemart.naranja), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.azul[f][c], sizeof(pricemart.azul), 1, bodega);
}
}
fclose(bodega);
}
}//fin de grabar
#include<iostream>
#include<stdio.h>
using namespace std;
const int cad=100;
const int maxi=4;
char findelinea[cad ];//
FILE *bodega;
struct pasillos//lote general del producto
{
//
char pasillo;
char estante[cad];
int codigo;//codigo de producto
char producto[cad];
int piezas;//cantidad de productos en el lote
char vencimiento[cad];
int contador;
char ubicacion[cad];//
int status; //para cuando compares solo busca en la referencia
};
struct Bodega
{
struct pasillos blanco[maxi][maxi];
struct pasillos amarillo[maxi][maxi];
struct pasillos negro[maxi][maxi];
struct pasillos rojo[maxi][maxi];
struct pasillos plata[maxi][maxi];
struct pasillos verde[maxi][maxi];
struct pasillos lila[maxi][maxi];
struct pasillos cafe[maxi][maxi];
struct pasillos naranja[maxi][maxi];
struct pasillos azul[maxi][maxi];
}pricemart;
void llenarpricemart(){//lo utiliso solo para llenar de ceros el archivo
cout<<"LLENAR ALMACEN"<<endl;
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.blanco[f][c].status=0;
pricemart.blanco[f][c].pasillo='A';
strcpy(pricemart.blanco[f][c].estante,"BLANCO");
sprintf (pricemart.blanco[f][c].ubicacion, "%c%s%i%i ",pricemart.blanco[f][c].pasillo,pricemart.blanco[f][c].estante,f+1,c+1 );
pricemart.blanco[f][c].codigo=0;
strcpy(pricemart.blanco[f][c].producto,"0");
pricemart.blanco[f][c].piezas=0;
strcpy(pricemart.blanco[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.amarillo[f][c].status=0;
pricemart.amarillo[f][c].pasillo='A';
strcpy(pricemart.amarillo[f][c].estante,"AMARILLO");
sprintf (pricemart.amarillo[f][c].ubicacion, "%c%s%i%i ",pricemart.amarillo[f][c].pasillo,pricemart.amarillo[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.amarillo[f][c].codigo=0;
strcpy(pricemart.amarillo[f][c].producto,"0");
pricemart.amarillo[f][c].piezas=0;
strcpy(pricemart.amarillo[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.negro[f][c].status=0;
pricemart.negro[f][c].pasillo='B';
strcpy(pricemart.negro[f][c].estante,"NEGRO");
sprintf (pricemart.negro[f][c].ubicacion, "%c%s%i%i ",pricemart.negro[f][c].pasillo,pricemart.negro[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.negro[f][c].codigo=0;
strcpy(pricemart.negro[f][c].producto,"0");
pricemart.negro[f][c].piezas=0;
strcpy(pricemart.negro[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.rojo[f][c].status=0;
pricemart.rojo[f][c].pasillo='B';
strcpy(pricemart.rojo[f][c].estante,"ROJO");
sprintf (pricemart.rojo[f][c].ubicacion, "%c%s%i%i ",pricemart.rojo[f][c].pasillo,pricemart.rojo[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.rojo[f][c].codigo=0;
strcpy(pricemart.rojo[f][c].producto,"0");
pricemart.rojo[f][c].piezas=0;
strcpy(pricemart.rojo[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.plata[f][c].status=0;
pricemart.plata[f][c].pasillo='C';
strcpy(pricemart.plata[f][c].estante,"PLATA");
sprintf (pricemart.plata[f][c].ubicacion, "%c%s%i%i ",pricemart.plata[f][c].pasillo,pricemart.plata[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.plata[f][c].codigo=0;
strcpy(pricemart.plata[f][c].producto,"0");
pricemart.plata[f][c].piezas=0;
strcpy(pricemart.plata[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.verde[f][c].status=0;
pricemart.verde[f][c].pasillo='C';
strcpy(pricemart.verde[f][c].estante,"VERDE");
sprintf (pricemart.verde[f][c].ubicacion, "%c%s%i%i ",pricemart.verde[f][c].pasillo,pricemart.verde[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.verde[f][c].codigo=0;
strcpy(pricemart.verde[f][c].producto,"0");
pricemart.verde[f][c].piezas=0;
strcpy(pricemart.verde[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.lila[f][c].status=0;
pricemart.lila[f][c].pasillo='D';
strcpy(pricemart.lila[f][c].estante,"LILA");
sprintf (pricemart.lila[f][c].ubicacion, "%c%s%i%i ",pricemart.lila[f][c].pasillo,pricemart.lila[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.lila[f][c].codigo=0;
strcpy(pricemart.lila[f][c].producto,"0");
pricemart.lila[f][c].piezas=0;
strcpy(pricemart.lila[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.cafe[f][c].status=0;
pricemart.cafe[f][c].pasillo='D';
strcpy(pricemart.cafe[f][c].estante,"CAFE");
sprintf (pricemart.cafe[f][c].ubicacion, "%c%s%i%i ",pricemart.cafe[f][c].pasillo,pricemart.cafe[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.cafe[f][c].codigo=0;
strcpy(pricemart.cafe[f][c].producto,"0");
pricemart.cafe[f][c].piezas=0;
strcpy(pricemart.cafe[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.naranja[f][c].status=0;
pricemart.naranja[f][c].pasillo='E';
strcpy(pricemart.naranja[f][c].estante,"NARANJA");
sprintf (pricemart.naranja[f][c].ubicacion, "%c%s%i%i ",pricemart.naranja[f][c].pasillo,pricemart.naranja[f][c].estante,f+1,c+1 );
fflush(stdin);
pricemart.naranja[f][c].codigo=0;
strcpy(pricemart.naranja[f][c].producto,"0");
pricemart.naranja[f][c].piezas=0;
strcpy(pricemart.naranja[f][c].vencimiento,"0");
}}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
pricemart.azul[f][c].status=0;
pricemart.azul[f][c].pasillo='E';
strcpy(pricemart.azul[f][c].estante,"AZUL");
sprintf (pricemart.azul[f][c].ubicacion, "%c%s%i%i ",pricemart.azul[f][c].pasillo,pricemart.azul[f][c].estante,f+1,c+1 );
pricemart.azul[f][c].codigo=0;
strcpy(pricemart.azul[f][c].producto,"0");
pricemart.azul[f][c].piezas=0;
strcpy(pricemart.azul[f][c].vencimiento,"0");
fflush(stdin);}}
}//fin de llenado
void mostrarpricemart(){
cout<<"lista de productos"<<endl;
cout<<"PASILLO "<<"ESTANTE "<<"UBICACION "<<"CODIGO " <<"NOMBRE " <<"PIEZAS " <<"F VENCIMIENTO "<<endl;
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
cout<<" "<<pricemart.blanco[f][c].pasillo<<"\t " << pricemart.blanco[f][c].estante <<" "<< pricemart.blanco[f][c].ubicacion<<" " << pricemart.blanco[f][c].codigo<<"\t " << pricemart.blanco[f][c].producto<<" \t" << pricemart.blanco[f][c].piezas<<"\t " << pricemart.blanco[f][c].vencimiento <<endl;
}
}
for(int f=0; f<maxi; f++){
for(int c=0; c<maxi; c++){
cout<<" "<<pricemart.amarillo[f][c].pasillo<<"\t " << pricemart.amarillo[f][c].estante <<" "<< pricemart.amarillo[f][c].ubicacion<<" " << pricemart.amarillo[f][c].codigo<<"\t " << pricemart.amarillo[f][c].producto<<" \t" << pricemart.amarillo[f][c].piezas<<"\t " << pricemart.amarillo[f][c].vencimiento <<endl;
}
}
}//fin de mostrar datos
void grabar_fichero (){
int f,c;
bodega = fopen("price1.dat", "wb");
if (bodega == NULL){
printf ("\nERROR: No se ha podido abrir el archivo pricemat ");
system("pause");
exit(0);
}
else{
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.blanco[f][c], sizeof(pricemart.blanco), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.amarillo[f][c], sizeof(pricemart.amarillo), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.negro[f][c], sizeof(pricemart.negro), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.rojo[f][c], sizeof(pricemart.rojo), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.plata[f][c], sizeof(pricemart.plata), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.verde[f][c], sizeof(pricemart.verde), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.lila[f][c], sizeof(pricemart.lila), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.cafe[f][c], sizeof(pricemart.cafe), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.naranja[f][c], sizeof(pricemart.naranja), 1, bodega);
}
}
for (f=0; f<maxi; f++){
for (c=0; c<maxi; c++){
fwrite(&pricemart.azul[f][c], sizeof(pricemart.azul), 1, bodega);
}
}
fclose(bodega);
}
}//fin de grabar
void cargar_fichero(){//inicio de cargar fichero
bodega=fopen("price1.dat","rb");
if(bodega==NULL){
cout<<"ERROR!!!!!"<<endl;
cout<<"No se puede abrir el archivo"<<endl;
cout<<"Compruebe que el archivo exita o intente otra vez"<<endl;
system("pause");
}
else{
while(!feof(bodega)){
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.blanco[f][c],sizeof(pricemart.blanco),1,bodega);
cout<<" "<<pricemart.blanco[f][c].pasillo<<"\t " << pricemart.blanco[f][c].estante <<" "<< pricemart.blanco[f][c].ubicacion<<" " << pricemart.blanco[f][c].codigo<<"\t " << pricemart.blanco[f][c].producto<<" \t" << pricemart.blanco[f][c].piezas<<"\t " << pricemart.blanco[f][c].vencimiento<<" "<<pricemart.blanco[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.amarillo[f][c],sizeof(pricemart.amarillo),1,bodega);
cout<<" "<<pricemart.amarillo[f][c].pasillo<<"\t " << pricemart.amarillo[f][c].estante <<" "<< pricemart.amarillo[f][c].ubicacion<<" " << pricemart.amarillo[f][c].codigo<<"\t " << pricemart.amarillo[f][c].producto<<" \t" << pricemart.amarillo[f][c].piezas<<"\t " << pricemart.amarillo[f][c].vencimiento<<" "<<pricemart.amarillo[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.negro[f][c],sizeof(pricemart.negro),1,bodega);
cout<<" "<<pricemart.negro[f][c].pasillo<<"\t " << pricemart.negro[f][c].estante <<" "<< pricemart.negro[f][c].ubicacion<<" " << pricemart.negro[f][c].codigo<<"\t " << pricemart.negro[f][c].producto<<" \t" << pricemart.negro[f][c].piezas<<"\t " << pricemart.negro[f][c].vencimiento<<" "<<pricemart.negro[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.rojo[f][c],sizeof(pricemart.rojo),1,bodega);
cout<<" "<<pricemart.rojo[f][c].pasillo<<"\t " << pricemart.rojo[f][c].estante <<" "<< pricemart.rojo[f][c].ubicacion<<" " << pricemart.rojo[f][c].codigo<<"\t " << pricemart.rojo[f][c].producto<<" \t" << pricemart.rojo[f][c].piezas<<"\t " << pricemart.rojo[f][c].vencimiento<<" "<<pricemart.rojo[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.plata[f][c],sizeof(pricemart.plata),1,bodega);
cout<<" "<<pricemart.plata[f][c].pasillo<<"\t " << pricemart.plata[f][c].estante <<" "<< pricemart.plata[f][c].ubicacion<<" " << pricemart.plata[f][c].codigo<<"\t " << pricemart.plata[f][c].producto<<" \t" << pricemart.plata[f][c].piezas<<"\t " << pricemart.plata[f][c].vencimiento<<" "<<pricemart.plata[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.verde[f][c],sizeof(pricemart.verde),1,bodega);
cout<<" "<<pricemart.verde[f][c].pasillo<<"\t " << pricemart.verde[f][c].estante <<" "<< pricemart.verde[f][c].ubicacion<<" " << pricemart.verde[f][c].codigo<<"\t " << pricemart.verde[f][c].producto<<" \t" << pricemart.verde[f][c].piezas<<"\t " << pricemart.verde[f][c].vencimiento<<" "<<pricemart.verde[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.lila[f][c],sizeof(pricemart.lila),1,bodega);
cout<<" "<<pricemart.lila[f][c].pasillo<<"\t " << pricemart.lila[f][c].estante <<" "<< pricemart.lila[f][c].ubicacion<<" " << pricemart.lila[f][c].codigo<<"\t " << pricemart.lila[f][c].producto<<" \t" << pricemart.lila[f][c].piezas<<"\t " << pricemart.lila[f][c].vencimiento<<" "<<pricemart.lila[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.cafe[f][c],sizeof(pricemart.cafe),1,bodega);
cout<<" "<<pricemart.cafe[f][c].pasillo<<"\t " << pricemart.cafe[f][c].estante <<" "<< pricemart.cafe[f][c].ubicacion<<" " << pricemart.cafe[f][c].codigo<<"\t " << pricemart.cafe[f][c].producto<<" \t" << pricemart.cafe[f][c].piezas<<"\t " << pricemart.cafe[f][c].vencimiento<<" "<<pricemart.cafe[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.naranja[f][c],sizeof(pricemart.naranja),1,bodega);
cout<<" "<<pricemart.naranja[f][c].pasillo<<"\t " << pricemart.naranja[f][c].estante <<" "<< pricemart.naranja[f][c].ubicacion<<" " << pricemart.naranja[f][c].codigo<<"\t " << pricemart.naranja[f][c].producto<<" \t" << pricemart.naranja[f][c].piezas<<"\t " << pricemart.naranja[f][c].vencimiento<<" "<<pricemart.naranja[f][c].status <<endl;}}
for (int f=0; f<maxi; f++){
for (int c=0; c<maxi; c++){
fread(&pricemart.azul[f][c],sizeof(pricemart.azul),1,bodega);
cout<<" "<<pricemart.azul[f][c].pasillo<<"\t " << pricemart.azul[f][c].estante <<" "<< pricemart.azul[f][c].ubicacion<<" " << pricemart.azul[f][c].codigo<<"\t " << pricemart.azul[f][c].producto<<" \t" << pricemart.azul[f][c].piezas<<"\t " << pricemart.azul[f][c].vencimiento<<" "<<pricemart.azul[f][c].status <<endl;}}
}
fclose(bodega);
}
}//fin de cargar fichero
/* int menu(){//MENU DE OPCIONES
system("color 0a");
system("cls");
int opcion;
do{
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
cout<<"\t "<<"+++++ "<<"A L M A C E N P R I X E M A R T 'S"<<" +++++\n";
cout<<"\t "<<"+++++ "<<"C E N T R A L DE O P E R A C I O N E S"<<" +++++\n";
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
cout<<"\t\t\t "<<"+++++ "<<"MENU PRINCIPAL"<<" +++++\n";
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout<<"\t** "<<"1.- INGRESAR LOTE DE PRODUCTOS\n";
cout<<"\t** "<<"2.- SALIDA DE LOTE(S)DE PRODUCTO(S)\n";
cout<<"\t** "<<"3.- REUBICACION DE PRODUCTOS\n";
cout<<"\t** "<<"4.- LISTA DE PRODUCTOS\n";
cout<<"\t** "<<"5.- CONSULTAR POR PRODUCTO\n";
cout<<"\t** "<<"0.- SALIR\n";
cout<<"ingrese su opcion"<<endl;
fflush (stdin);
scanf("%d",&opcion);
}while((opcion<0) || (opcion>5 ));
return opcion;
}//FIN DE MENU
*/
//programa principal
main (){
/*int opc; //al utilizar este codigo el fichero no se carga
bool salir=false;
cargar_fichero();//el problema es aqui el fichero no se carga
system("pause");
mostrarpricemart();
system("pause");
while(!salir)
{
opc=menu();
switch(opc){
case 1: cout<<"ingreso lote de productos"<<endl;
cargar_fichero();
system("pause");
break;
case 2: cout<<"salida lote de productos"<<endl;
mostrarpricemart();
system("pause");
break;
case 3: cout<<"reubicacion"<<endl;
system("pause");
break;
case 4: cout<<"lista de productos"<<endl;
system("pause");
break;
case 5: cout<<"consultar por productos"<<endl;
system("pause");
break;
default: cout<<"Ingreso no valido intente otra vez"<<endl;
system("pause");
break;
case 0:
cout<<"HA SALIDO DE LA APLICACION"<<endl;
salir=true;
break;
}//fin de swicht
}//fin de while
*/
cargar_fichero(); // Aqui carga el fichero el problema es que al unirlo al switch ya no carga
//al eliminar este codigo y utilizar el sitch ya no carga el fichero
//llenarpricemart(); //lo utilice una vez para llenar el archivo de ceros
system("pause");
grabar_fichero();
system("pause");
cargar_fichero();
system("pause");
}