elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  ayuda para crear bodega en c++
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: ayuda para crear bodega en c++  (Leído 9,760 veces)
krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
ayuda para crear bodega en c++
« en: 5 Junio 2012, 06:51 am »

Hola soy muy novato en programacion y necesito que por favor me den algunas ideas para empezar a hacer un programa que me pidieron en un curso.
necesito ideas de como empezar y asi voy creando el codigo y publicando mis dudas para resolverlas. habia pensado en una lista perono se si esta bien.
aqui  dejo la informacion. de antemano gracias por la ayuda

crear un sistema que tenga la capacidad de administrar los productos que se almacenan en la Bodega , esta está organizada en pasillos, donde cada uno cuenta con dos Estanterías, que cada una de ellas tiene 4 niveles y a su vez 4 columnas donde se organizan los lotes de productos.  Debe considerarse que un lote de producto tiene un código, el nombre del producto, cantidad de productos en el lote y fecha de vencimiento del producto. De tal manera que se debe despachar aquel producto que este más pronto a vencer. La bodega está organizada así:

los productos son colocados con el montacargas y colocados en la ubicación que se identifica por el código siguiente FROJO11, que indica F, pasillo, ROJO el estante, 1 Nivel y 1 columna del estante.son diez estantes osea diez colores.
 ¿¿¿¿tengo que hacer diez listas y unirlas??????
en cada pasillo puedo almacenar 16 lotes de productos osea 4 niveles y 4 columnas

El sistema debe permitir
1.   Dar ingreso a un lote nuevo, proporcionando la ubicación que esta próxima disponible, considerar la fecha de vencimiento, para que los productos más viejos estén más cerca.
2.   Dar salida a una lista de lotes de producto, según solicitud de un cliente. Considerando que puede pedir varios y serán enviados en un camión.
3.   Reubicar un producto, cuando un producto este próximo a vencer debe moverse a una ubicación más cercana de haber lugares disponibles.

atte. krizalid1     :huh:


En línea

maxim_o

Desconectado Desconectado

Mensajes: 186


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #1 en: 5 Junio 2012, 11:14 am »

mmmm yo mas bien usaria una estructura.... con cada "variable" necesaria.
y las vas guardando en un archivo.....
Asi aunque cierres el programa sigues teniendo los datos en la memoria....


En línea

krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #2 en: 5 Junio 2012, 20:27 pm »

Crees que con una estructura solucionaria el problema porque tendria diez pasillos cada pasillo 4 niveles y 4 renglones por nivel quedaria algo asi

pasillo Azul  [1,1][1,2][1,3][1,4] 4 niveles y 4 renglones  serian 16 bloques
                  [2,1][2,2][2,3][2,4]
                  [3,1][3,2][3,3][3,4]
                  [4,1][4,2][4,3][4,4]

pasillo Rojo  [1,1][1,2][1,3][1,4] 4 niveles y 4 renglones  serian 16 bloques
                  [2,1][2,2][2,3][2,4]
                  [3,1][3,2][3,3][3,4]
                  [4,1][4,2][4,3][4,4]

seria algo asi y  ocho pasillos mas el usuario al momento de buscar solo ingresaria
un codigo FAZUL11 f=pasillo azul el estante 1 nivel 1 renglon. y para buscar en otro pasillo FROJOL14.
de aqui no se como iniciarlo porque tendria que unir todos los pasillo para buscar??
y devolver el resultado y poder mostrar todos los datos de los pasillos.
Por eso no se que tipo de estructura debo usar, pero dejame probar con una estructura haber como queda. si alguien tiene una idea mejor le agradeceria mucho la informacion .
En línea

maxim_o

Desconectado Desconectado

Mensajes: 186


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #3 en: 6 Junio 2012, 10:04 am »

UNa estructura con el nombre del pruducto, cantidad de productos en ese lote, y la fecha de caducidad.

Luego en la funcion de añadir producto abres el archivo en modo lectura y creas otro archivo auxiliar en modo escritura, vas leyendo las estructuras y comparando las fechas con el nuevo producto.
Vas escribiendo en el auxiliar "producto a producto" con un for y comparando las fechas con el nuevo , mientras la fecha de los productos "caduque" antes que la del nuevo produzto vas escribiendo en el archivo auxiliar esos y cuando la del nuevo producto caduque antes que uno del archivo escribes primero el nuevo y despues el viejo....

Asi grabarias en el archivo todos los produzctos por orden de la fecha de caducidad.
Cierras los archivos.
Borras el  antiguo archivo, y renombras el auxiliar a ese mismo nombre.

y ya tendrias todo ordenadito, ya la hora de listar es saber los numeros a que posiciones de pasillo y tal corresponden.... y con if mostrarlo

Por ejemplo tienes el numero 24...
Sabes que los 16 primeros numeros corresponden al pasillo 1
los 16 siguientes al 2 , etc etc

Por lo tanto estariamos en el pasillo 2 (numero 24), estariamos en el nivel 2 en la ultima posicion...
Vamos todo va por multiplos ...

1-16 (pasillo 1)---------> del 1 al 4 primer nivel , del 5 al 8, segundo nivel, etc etc




PD: Te lo explicao segun tu ultimo post.... Pero segun el primero cada pasillo tiene dos estanterias.
Por lo que cada pasillo almacenaria 32 produzcos... 16 en una y 16 en otra....


Espero que lo hayas entendido...

Un saludo
En línea

krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #4 en: 6 Junio 2012, 17:10 pm »

Ok comienzo a trabajar en el codigo y te cuento como me queda


atte. krizalid
En línea

krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #5 en: 19 Junio 2012, 21:38 pm »

Bueno hasta aqui e llegado solo pero tengo un problema no si si el codigo este bien
para eso lo publico para que me ayuden a corregirlo y tambien porque tengo una duda. cuando quiero iniciar el programa me abre el archivo pero al unirle un switch
el programa no corre.
me pueden ayudar realmente necesito ayuda.


 :huh: :huh: :huh:





#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");
 
     }
     
     
     
En línea

durasno


Desconectado Desconectado

Mensajes: 373


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #6 en: 20 Junio 2012, 00:16 am »

Hola! usa la etiqueta GeSHi para poner codigo, tal ves asi la gente tenga mas ganas de responder
En línea

Ahorrate una pregunta, lee el man
krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #7 en: 20 Junio 2012, 05:34 am »

Ok gracias durasno.
Estaba revisando la forma de grabar en el archivo y corregir errores
pero si necesitaria alguna ayuda de alguien que sepa para orientarme y poder seguir con el codigo hasta completarlo.




Código
  1. #include<iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4.  
  5. const int cad=100;
  6. const int maxi=4;
  7. char findelinea[cad ];//
  8. FILE *bodega;
  9. struct pasillos//lote general del producto
  10.       {
  11.                //
  12.               char pasillo;
  13.               char estante[cad];
  14.               int codigo;//codigo de producto
  15.               char producto[cad];
  16.               int piezas;//cantidad de productos en el lote
  17.               char vencimiento[cad];
  18.               int contador;
  19.               char ubicacion[cad];//
  20.               int status;                      //para cuando compares solo busca en la referencia
  21.       };
  22.  
  23. struct Bodega
  24.       {      
  25.              struct pasillos blanco[maxi][maxi];
  26.              struct pasillos amarillo[maxi][maxi];
  27.              struct pasillos negro[maxi][maxi];
  28.              struct pasillos rojo[maxi][maxi];
  29.              struct pasillos plata[maxi][maxi];
  30.              struct pasillos verde[maxi][maxi];
  31.              struct pasillos lila[maxi][maxi];
  32.              struct pasillos cafe[maxi][maxi];
  33.              struct pasillos naranja[maxi][maxi];
  34.              struct pasillos azul[maxi][maxi];
  35.       }pricemart;
  36.  
  37. void llenarpricemart(){//lo utiliso solo para llenar de ceros el archivo
  38.     cout<<"LLENAR ALMACEN"<<endl;
  39.        for(int f=0; f<maxi; f++){
  40.                for(int c=0; c<maxi; c++){
  41.                        pricemart.blanco[f][c].status=0;
  42.                        pricemart.blanco[f][c].pasillo='A';
  43.                        strcpy(pricemart.blanco[f][c].estante,"BLANCO");
  44.                        sprintf (pricemart.blanco[f][c].ubicacion, "%c%s%i%i ",pricemart.blanco[f][c].pasillo,pricemart.blanco[f][c].estante,f+1,c+1 );
  45.                        pricemart.blanco[f][c].codigo=0;
  46.                        strcpy(pricemart.blanco[f][c].producto,"0");
  47.                        pricemart.blanco[f][c].piezas=0;
  48.                        strcpy(pricemart.blanco[f][c].vencimiento,"0");
  49.                        }}
  50.       for(int f=0; f<maxi; f++){
  51.                for(int c=0; c<maxi; c++){              
  52.                        pricemart.amarillo[f][c].status=0;  
  53.                        pricemart.amarillo[f][c].pasillo='A';
  54.                        strcpy(pricemart.amarillo[f][c].estante,"AMARILLO");
  55.                        sprintf (pricemart.amarillo[f][c].ubicacion, "%c%s%i%i ",pricemart.amarillo[f][c].pasillo,pricemart.amarillo[f][c].estante,f+1,c+1 );
  56.                        fflush(stdin);
  57.                        pricemart.amarillo[f][c].codigo=0;
  58.                        strcpy(pricemart.amarillo[f][c].producto,"0");
  59.                        pricemart.amarillo[f][c].piezas=0;
  60.                        strcpy(pricemart.amarillo[f][c].vencimiento,"0");
  61.                        }}
  62.  
  63.      for(int f=0; f<maxi; f++){
  64.                for(int c=0; c<maxi; c++){
  65.                        pricemart.negro[f][c].status=0;
  66.                        pricemart.negro[f][c].pasillo='B';
  67.                        strcpy(pricemart.negro[f][c].estante,"NEGRO");
  68.                        sprintf (pricemart.negro[f][c].ubicacion, "%c%s%i%i ",pricemart.negro[f][c].pasillo,pricemart.negro[f][c].estante,f+1,c+1 );
  69.                        fflush(stdin);
  70.                        pricemart.negro[f][c].codigo=0;
  71.                        strcpy(pricemart.negro[f][c].producto,"0");
  72.                        pricemart.negro[f][c].piezas=0;
  73.                        strcpy(pricemart.negro[f][c].vencimiento,"0");
  74.                        }}
  75.      for(int f=0; f<maxi; f++){
  76.                for(int c=0; c<maxi; c++){
  77.                        pricemart.rojo[f][c].status=0;
  78.                        pricemart.rojo[f][c].pasillo='B';
  79.                        strcpy(pricemart.rojo[f][c].estante,"ROJO");
  80.                        sprintf (pricemart.rojo[f][c].ubicacion, "%c%s%i%i ",pricemart.rojo[f][c].pasillo,pricemart.rojo[f][c].estante,f+1,c+1 );
  81.                        fflush(stdin);
  82.                        pricemart.rojo[f][c].codigo=0;
  83.                        strcpy(pricemart.rojo[f][c].producto,"0");
  84.                        pricemart.rojo[f][c].piezas=0;
  85.                        strcpy(pricemart.rojo[f][c].vencimiento,"0");
  86.                        }}
  87.     for(int f=0; f<maxi; f++){
  88.                for(int c=0; c<maxi; c++){
  89.                        pricemart.plata[f][c].status=0;
  90.                        pricemart.plata[f][c].pasillo='C';
  91.                        strcpy(pricemart.plata[f][c].estante,"PLATA");
  92.                        sprintf (pricemart.plata[f][c].ubicacion, "%c%s%i%i ",pricemart.plata[f][c].pasillo,pricemart.plata[f][c].estante,f+1,c+1 );
  93.                        fflush(stdin);
  94.                        pricemart.plata[f][c].codigo=0;
  95.                        strcpy(pricemart.plata[f][c].producto,"0");
  96.                        pricemart.plata[f][c].piezas=0;
  97.                        strcpy(pricemart.plata[f][c].vencimiento,"0");
  98.                        }}
  99.     for(int f=0; f<maxi; f++){
  100.                for(int c=0; c<maxi; c++){
  101.                        pricemart.verde[f][c].status=0;
  102.                        pricemart.verde[f][c].pasillo='C';
  103.                        strcpy(pricemart.verde[f][c].estante,"VERDE");
  104.                        sprintf (pricemart.verde[f][c].ubicacion, "%c%s%i%i ",pricemart.verde[f][c].pasillo,pricemart.verde[f][c].estante,f+1,c+1 );
  105.                        fflush(stdin);
  106.                        pricemart.verde[f][c].codigo=0;
  107.                        strcpy(pricemart.verde[f][c].producto,"0");
  108.                        pricemart.verde[f][c].piezas=0;
  109.                        strcpy(pricemart.verde[f][c].vencimiento,"0");
  110.                        }}
  111.     for(int f=0; f<maxi; f++){
  112.                for(int c=0; c<maxi; c++){
  113.                        pricemart.lila[f][c].status=0;
  114.                        pricemart.lila[f][c].pasillo='D';
  115.                        strcpy(pricemart.lila[f][c].estante,"LILA");
  116.                        sprintf (pricemart.lila[f][c].ubicacion, "%c%s%i%i ",pricemart.lila[f][c].pasillo,pricemart.lila[f][c].estante,f+1,c+1 );
  117.                        fflush(stdin);
  118.                        pricemart.lila[f][c].codigo=0;
  119.                        strcpy(pricemart.lila[f][c].producto,"0");
  120.                        pricemart.lila[f][c].piezas=0;
  121.                        strcpy(pricemart.lila[f][c].vencimiento,"0");
  122.                        }}
  123.     for(int f=0; f<maxi; f++){
  124.                for(int c=0; c<maxi; c++){
  125.                        pricemart.cafe[f][c].status=0;
  126.                        pricemart.cafe[f][c].pasillo='D';
  127.                        strcpy(pricemart.cafe[f][c].estante,"CAFE");
  128.                        sprintf (pricemart.cafe[f][c].ubicacion, "%c%s%i%i ",pricemart.cafe[f][c].pasillo,pricemart.cafe[f][c].estante,f+1,c+1 );
  129.                        fflush(stdin);
  130.                        pricemart.cafe[f][c].codigo=0;
  131.                        strcpy(pricemart.cafe[f][c].producto,"0");
  132.                        pricemart.cafe[f][c].piezas=0;
  133.                        strcpy(pricemart.cafe[f][c].vencimiento,"0");
  134.                        }}
  135.     for(int f=0; f<maxi; f++){
  136.                for(int c=0; c<maxi; c++){
  137.                        pricemart.naranja[f][c].status=0;
  138.                        pricemart.naranja[f][c].pasillo='E';
  139.                        strcpy(pricemart.naranja[f][c].estante,"NARANJA");
  140.                        sprintf (pricemart.naranja[f][c].ubicacion, "%c%s%i%i ",pricemart.naranja[f][c].pasillo,pricemart.naranja[f][c].estante,f+1,c+1 );
  141.                        fflush(stdin);
  142.                        pricemart.naranja[f][c].codigo=0;
  143.                        strcpy(pricemart.naranja[f][c].producto,"0");
  144.                        pricemart.naranja[f][c].piezas=0;
  145.                        strcpy(pricemart.naranja[f][c].vencimiento,"0");
  146.                        }}
  147.     for(int f=0; f<maxi; f++){
  148.                for(int c=0; c<maxi; c++){
  149.                        pricemart.azul[f][c].status=0;
  150.                        pricemart.azul[f][c].pasillo='E';
  151.                        strcpy(pricemart.azul[f][c].estante,"AZUL");
  152.                        sprintf (pricemart.azul[f][c].ubicacion, "%c%s%i%i ",pricemart.azul[f][c].pasillo,pricemart.azul[f][c].estante,f+1,c+1 );
  153.                        pricemart.azul[f][c].codigo=0;
  154.                        strcpy(pricemart.azul[f][c].producto,"0");
  155.                        pricemart.azul[f][c].piezas=0;
  156.                        strcpy(pricemart.azul[f][c].vencimiento,"0");
  157.                        fflush(stdin);}}
  158.  
  159.     }//fin de llenado
  160.  
  161. void mostrarpricemart(){
  162.     cout<<"lista de productos"<<endl;
  163.     cout<<"PASILLO    "<<"ESTANTE    "<<"UBICACION    "<<"CODIGO    "  <<"NOMBRE    "  <<"PIEZAS    "  <<"F VENCIMIENTO "<<endl;
  164.        for(int f=0; f<maxi; f++){
  165.                for(int c=0; c<maxi; c++){
  166.                        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;
  167.                }    
  168.        }        
  169.        for(int f=0; f<maxi; f++){
  170.                for(int c=0; c<maxi; c++){
  171.                        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;
  172.                }
  173.        }
  174.     }//fin de mostrar datos
  175.  
  176. void grabar_fichero (){
  177.  
  178.     int f,c;
  179.     bodega = fopen("price1.dat", "wb");
  180.     if (bodega == NULL){
  181.        printf ("\nERROR: No se ha podido abrir el archivo pricemat ");
  182.        system("pause");
  183.        exit(0);
  184.     }
  185.     else{
  186.         for (f=0; f<maxi; f++){
  187.             for (c=0; c<maxi; c++){
  188.             fwrite(&pricemart.blanco[f][c], sizeof(pricemart.blanco), 1, bodega);
  189.         }
  190.         }
  191.         for (f=0; f<maxi; f++){
  192.             for (c=0; c<maxi; c++){
  193.             fwrite(&pricemart.amarillo[f][c], sizeof(pricemart.amarillo), 1, bodega);
  194.         }
  195.         }
  196.         for (f=0; f<maxi; f++){
  197.             for (c=0; c<maxi; c++){
  198.             fwrite(&pricemart.negro[f][c], sizeof(pricemart.negro), 1, bodega);
  199.         }
  200.         }
  201.         for (f=0; f<maxi; f++){
  202.             for (c=0; c<maxi; c++){
  203.             fwrite(&pricemart.rojo[f][c], sizeof(pricemart.rojo), 1, bodega);
  204.         }
  205.         }
  206.         for (f=0; f<maxi; f++){
  207.             for (c=0; c<maxi; c++){
  208.             fwrite(&pricemart.plata[f][c], sizeof(pricemart.plata), 1, bodega);
  209.         }
  210.         }
  211.         for (f=0; f<maxi; f++){
  212.             for (c=0; c<maxi; c++){
  213.             fwrite(&pricemart.verde[f][c], sizeof(pricemart.verde), 1, bodega);
  214.         }
  215.         }
  216.         for (f=0; f<maxi; f++){
  217.             for (c=0; c<maxi; c++){
  218.             fwrite(&pricemart.lila[f][c], sizeof(pricemart.lila), 1, bodega);
  219.         }
  220.         }
  221.         for (f=0; f<maxi; f++){
  222.             for (c=0; c<maxi; c++){
  223.             fwrite(&pricemart.cafe[f][c], sizeof(pricemart.cafe), 1, bodega);
  224.         }
  225.         }
  226.         for (f=0; f<maxi; f++){
  227.             for (c=0; c<maxi; c++){
  228.             fwrite(&pricemart.naranja[f][c], sizeof(pricemart.naranja), 1, bodega);
  229.         }
  230.         }
  231.         for (f=0; f<maxi; f++){
  232.             for (c=0; c<maxi; c++){
  233.             fwrite(&pricemart.azul[f][c], sizeof(pricemart.azul), 1, bodega);
  234.         }
  235.         }
  236.         fclose(bodega);
  237.     }
  238. }//fin de grabar    
  239.  
  240. void cargar_fichero(){//inicio de cargar fichero
  241.          bodega=fopen("price1.dat","rb");
  242.           if(bodega==NULL){
  243.                cout<<"ERROR!!!!!"<<endl;
  244.                cout<<"No se puede abrir el archivo"<<endl;
  245.                cout<<"Compruebe que el archivo exita o intente otra vez"<<endl;            
  246.                system("pause");
  247.                }
  248.                else{
  249.  
  250.                   while(!feof(bodega)){
  251.  
  252.                        for (int f=0; f<maxi; f++){
  253.                            for (int c=0; c<maxi; c++){        
  254.                                fread(&pricemart.blanco[f][c],sizeof(pricemart.blanco),1,bodega);
  255.                                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;}}
  256.                        for (int f=0; f<maxi; f++){
  257.                            for (int c=0; c<maxi; c++){        
  258.                                fread(&pricemart.amarillo[f][c],sizeof(pricemart.amarillo),1,bodega);
  259.                                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;}}
  260.                        for (int f=0; f<maxi; f++){
  261.                            for (int c=0; c<maxi; c++){        
  262.                                fread(&pricemart.negro[f][c],sizeof(pricemart.negro),1,bodega);
  263.                                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;}}    
  264.                        for (int f=0; f<maxi; f++){
  265.                            for (int c=0; c<maxi; c++){        
  266.                                fread(&pricemart.rojo[f][c],sizeof(pricemart.rojo),1,bodega);
  267.                                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;}}    
  268.                        for (int f=0; f<maxi; f++){
  269.                            for (int c=0; c<maxi; c++){        
  270.                                fread(&pricemart.plata[f][c],sizeof(pricemart.plata),1,bodega);
  271.                                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;}}    
  272.                        for (int f=0; f<maxi; f++){
  273.                            for (int c=0; c<maxi; c++){        
  274.                                fread(&pricemart.verde[f][c],sizeof(pricemart.verde),1,bodega);
  275.                                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;}}    
  276.                        for (int f=0; f<maxi; f++){
  277.                            for (int c=0; c<maxi; c++){        
  278.                                fread(&pricemart.lila[f][c],sizeof(pricemart.lila),1,bodega);
  279.                                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;}}        
  280.                       for (int f=0; f<maxi; f++){
  281.                            for (int c=0; c<maxi; c++){        
  282.                                fread(&pricemart.cafe[f][c],sizeof(pricemart.cafe),1,bodega);
  283.                                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;}}        
  284.                       for (int f=0; f<maxi; f++){
  285.                            for (int c=0; c<maxi; c++){        
  286.                                fread(&pricemart.naranja[f][c],sizeof(pricemart.naranja),1,bodega);
  287.                                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;}}        
  288.                       for (int f=0; f<maxi; f++){
  289.                            for (int c=0; c<maxi; c++){        
  290.                                fread(&pricemart.azul[f][c],sizeof(pricemart.azul),1,bodega);
  291.                                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;}}            
  292.                    }
  293.                     fclose(bodega);              
  294.                }  
  295.  
  296.     }//fin de cargar fichero
  297.  
  298.  /* int menu(){//MENU DE OPCIONES
  299.     system("color 0a");
  300.     system("cls");
  301.     int opcion;
  302.     do{
  303.     cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
  304.     cout<<"\t     "<<"+++++ "<<"A L M A C E N         P R I X E M A R T 'S"<<" +++++\n";
  305.     cout<<"\t     "<<"+++++ "<<"C E N T R A L   DE   O P E R A C I O N E S"<<" +++++\n";
  306.     cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";  
  307.  
  308.     cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
  309.     cout<<"\t\t\t "<<"+++++ "<<"MENU  PRINCIPAL"<<" +++++\n";
  310.     cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
  311.     cout<<"\t** "<<"1.-  INGRESAR LOTE DE PRODUCTOS\n";
  312.     cout<<"\t** "<<"2.-  SALIDA DE LOTE(S)DE PRODUCTO(S)\n";
  313.     cout<<"\t** "<<"3.-  REUBICACION DE PRODUCTOS\n";
  314.     cout<<"\t** "<<"4.-  LISTA DE PRODUCTOS\n";
  315.     cout<<"\t** "<<"5.-  CONSULTAR POR PRODUCTO\n";
  316.                    
  317.     cout<<"\t** "<<"0.- SALIR\n";
  318.     cout<<"ingrese su opcion"<<endl;
  319.     fflush (stdin);
  320.     scanf("%d",&opcion);
  321.    
  322.     }while((opcion<0) || (opcion>5 ));
  323.     return opcion;
  324.             }//FIN DE MENU
  325.  
  326. */
  327.  
  328.  
  329. //programa principal
  330. main (){
  331.       /*int opc; //al utilizar este codigo el fichero no se carga
  332.      bool salir=false;
  333.  
  334.      cargar_fichero();//el problema es aqui el fichero no se carga
  335.      system("pause");
  336.      mostrarpricemart();
  337.      system("pause");
  338.      while(!salir)
  339.      {
  340.       opc=menu();
  341.           switch(opc){
  342.                       case 1: cout<<"ingreso lote de productos"<<endl;
  343.                               cargar_fichero();
  344.                               system("pause");              
  345.                       break;
  346.                       case 2: cout<<"salida lote de productos"<<endl;
  347.                               mostrarpricemart();
  348.                               system("pause");              
  349.                       break;
  350.                       case 3: cout<<"reubicacion"<<endl;
  351.                               system("pause");              
  352.                       break;
  353.                       case 4: cout<<"lista de productos"<<endl;
  354.                               system("pause");              
  355.                       break;
  356.                       case 5: cout<<"consultar por productos"<<endl;
  357.                               system("pause");              
  358.                       break;
  359.                       default: cout<<"Ingreso no valido intente otra vez"<<endl;
  360.                                system("pause");              
  361.                       break;
  362.                       case 0:
  363.                              cout<<"HA SALIDO DE LA APLICACION"<<endl;
  364.                              salir=true;
  365.                       break;
  366.                      
  367.                       }//fin de swicht            
  368.       }//fin de while
  369.      
  370.  
  371.   */  
  372. cargar_fichero();        // Aqui carga el fichero el problema es que al unirlo al switch ya no carga
  373. //al eliminar este codigo y utilizar el sitch ya no carga el fichero
  374. //llenarpricemart(); //lo utilice una vez para llenar el archivo de ceros
  375. system("pause");
  376.  
  377. grabar_fichero();
  378. system("pause");
  379. cargar_fichero();  
  380. system("pause");
  381.  
  382.     }
En línea

krizalid1

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #8 en: 21 Junio 2012, 19:21 pm »

Ayuda con esta funcion ???????
Código
  1. void grabar_fichero (){
  2.  
  3.     int f,c;
  4.     bodega = fopen("price1.dat", "wb");
  5.     if (bodega == NULL){
  6.        printf ("\nERROR: No se ha podido abrir el archivo pricemat ");
  7.        system("pause");
  8.        exit(0);
  9.     }
  10.     else{
  11.         for (f=0; f<maxi; f++){
  12.             for (c=0; c<maxi; c++){
  13.             fwrite(&pricemart.blanco[f][c], sizeof(pricemart.blanco), 1, bodega);
  14.         }
  15.         }
  16.         for (f=0; f<maxi; f++){
  17.             for (c=0; c<maxi; c++){
  18.             fwrite(&pricemart.amarillo[f][c], sizeof(pricemart.amarillo), 1, bodega);
  19.         }
  20.         }
  21.         for (f=0; f<maxi; f++){
  22.             for (c=0; c<maxi; c++){
  23.             fwrite(&pricemart.negro[f][c], sizeof(pricemart.negro), 1, bodega);
  24.         }
  25.         }
  26.         for (f=0; f<maxi; f++){
  27.             for (c=0; c<maxi; c++){
  28.             fwrite(&pricemart.rojo[f][c], sizeof(pricemart.rojo), 1, bodega);
  29.         }
  30.         }
  31.         for (f=0; f<maxi; f++){
  32.             for (c=0; c<maxi; c++){
  33.             fwrite(&pricemart.plata[f][c], sizeof(pricemart.plata), 1, bodega);
  34.         }
  35.         }
  36.         for (f=0; f<maxi; f++){
  37.             for (c=0; c<maxi; c++){
  38.             fwrite(&pricemart.verde[f][c], sizeof(pricemart.verde), 1, bodega);
  39.         }
  40.         }
  41.         for (f=0; f<maxi; f++){
  42.             for (c=0; c<maxi; c++){
  43.             fwrite(&pricemart.lila[f][c], sizeof(pricemart.lila), 1, bodega);
  44.         }
  45.         }
  46.         for (f=0; f<maxi; f++){
  47.             for (c=0; c<maxi; c++){
  48.             fwrite(&pricemart.cafe[f][c], sizeof(pricemart.cafe), 1, bodega);
  49.         }
  50.         }
  51.         for (f=0; f<maxi; f++){
  52.             for (c=0; c<maxi; c++){
  53.             fwrite(&pricemart.naranja[f][c], sizeof(pricemart.naranja), 1, bodega);
  54.         }
  55.         }
  56.         for (f=0; f<maxi; f++){
  57.             for (c=0; c<maxi; c++){
  58.             fwrite(&pricemart.azul[f][c], sizeof(pricemart.azul), 1, bodega);
  59.         }
  60.         }
  61.         fclose(bodega);
  62.     }
  63. }//fin de grabar
En línea

durasno


Desconectado Desconectado

Mensajes: 373


Ver Perfil
Re: ayuda para crear bodega en c++
« Respuesta #9 en: 22 Junio 2012, 09:12 am »

Hola! creo haber encontrado el error :)

La funcion fwrite, como ya sabes recibe 4 argumentos, el primero es un puntero que apunta a lo que se va a guardar y el segundo especifica el tamaño de lo que se guarda, aqui el problema. Tomemos como ejemplo pricemart.blanco:
 blanco es una matriz de struct pasillos entonces blanco[f][c] es UNA struct pasillos. Por lo tanto si haces un sizeof(pricemart.blanco) y sizeof(pricemart.blanco[f][c]) tenes dos tamaños totalmente diferentes, el primero devuelve el tamaño de la matriz y el segundo el de una struct pasillos (en otras palabras estas guardando en un bloque de memoria grande algo muy chiquito)
Resumiendo deberia ser asi:
Código
  1. for (f=0; f<maxi; f++){
  2.             for (c=0; c<maxi; c++){
  3.             fwrite(&pricemart.blanco[f][c], sizeof(struct pasillos), 1, bodega);
  4.         }
  5.         }

Creo(no estoy seguro) que tambien funcionaria asi:
Código
  1. fwrite(pricemart.blanco, sizeof(pricemart.blanco), 1, bodega); // sin los for, sin nada


Si te funciona alguno de los dos, acordate de usar el mismo concepto para fread

Saludos
En línea

Ahorrate una pregunta, lee el man
Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda para crear menus interactibos tipo dvd para vcd
Multimedia
warriorlost 3 4,394 Último mensaje 29 Diciembre 2005, 13:42 pm
por Sourraund
[Ayuda] Necesito ayuda para crear un buen video uso AF y Flash.
Diseño Gráfico
XXXXXX 1 5,505 Último mensaje 11 Noviembre 2009, 00:17 am
por Sub_Cero
Ayuda! Como serian los codigos para crear un programa para ver ip (y explicacion
.NET (C#, VB.NET, ASP)
gonzalo57 4 3,876 Último mensaje 4 Junio 2012, 20:56 pm
por 79137913
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines