SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <stdio.h> | |
| 2 | ||
| 3 | typedef struct{
| |
| 4 | lnodo *head; | |
| 5 | lnodo *curr; | |
| 6 | lnodo *tail; | |
| 7 | unsigned int listsize; | |
| 8 | unsigned int currpos; | |
| 9 | }tlist; | |
| 10 | ||
| 11 | typedef struct{
| |
| 12 | cnodo *head; | |
| 13 | cnodo *tail; | |
| 14 | unsigned int listsize; | |
| 15 | }tcola; | |
| 16 | ||
| 17 | typedef struct{
| |
| 18 | tcola *ids; | |
| 19 | lnodo *next; | |
| 20 | lnodo *prev; | |
| 21 | int stock; | |
| 22 | int precio; | |
| 23 | char* prod = (char*)malloc(20 * sizeof(char)); | |
| 24 | char* id_p = (char*)malloc(10 * sizeof(char)); | |
| 25 | }lnodo; | |
| 26 | ||
| 27 | typedef struct{
| |
| 28 | cnodo *prev; | |
| 29 | cnodo *next; | |
| 30 | char* id_u = (char*)malloc(10 * sizeof(char)); | |
| 31 | }cnodo; | |
| 32 | ||
| 33 | //implementacion de funciones de listas y colas | |
| 34 | ||
| 35 | int main(){
| |
| 36 | tlist *L; | |
| 37 | initlista(L); | |
| 38 | FILE *input; | |
| 39 | input=fopen("input.dat","r");
| |
| 40 | - | char pala[100], opcion, opcion1, pala1[100], nombrep[40], precio[20], idt[20], idu[20]; |
| 40 | + | char pala[100], opcion, opcion1, nombrep[40], precio[20], idt[20], idu[20]; |
| 41 | int ind=0, ind1=0, dia=0; | |
| 42 | while((opcion=fgetc(input))==1){
| |
| 43 | pala[ind]=opcion; | |
| 44 | ind++ | |
| 45 | if (opcion=="-"){
| |
| 46 | if (pala=="inicio"){
| |
| 47 | FILE *inicial; | |
| 48 | inicial=fopen("inicial.dat","r");
| |
| 49 | while ((opcion1=fgetc(inicial))==1){
| |
| 50 | if (opcion1=='\"'){
| |
| 51 | fseek(inicial,-1,SEEK_CUR); | |
| 52 | fscanf(inicial,"%s %s %s %s\n", nombrep, idt, idu, precio); | |
| 53 | /*Creamos un lnodo en la lista, lo llenamos con la informacion, creamos una cola dentro del nodo y llenamos el cnodo con el idu*/ | |
| 54 | } | |
| 55 | else if (opcion1=="\n"){
| |
| 56 | continue; | |
| 57 | } | |
| 58 | else{
| |
| 59 | fseek(inicial,-1,SEEK_CUR); | |
| 60 | fscanf(inicial, "%s %s\n", idt, idu); | |
| 61 | /*buscamos el lnodo que corresponde al idt en la lista y creamos un cnodo en la cola correspondiente*/ | |
| 62 | } | |
| 63 | } | |
| 64 | fclose(inicial); | |
| 65 | dia++ | |
| 66 | } | |
| 67 | else if (pala=="dia"){
| |
| 68 | fscanf(input, "siguiente\n"); | |
| 69 | dia++; | |
| 70 | } | |
| 71 | else if (pala=="ingreso "){
| |
| 72 | fscanf(input,"nombre %s -idt %s -idu %s -precio %s\n", nombrep, idt, idu, precio); | |
| 73 | /*Creamos un lnodo en la lista, lo llenamos con la informacion, creamos una cola dentro del nodo y llenamos el cnodo con el idu*/ | |
| 74 | } | |
| 75 | else if (pala=="egreso "){
| |
| 76 | fscanf(input, "idt %s -idu %s\n",idt,idu); | |
| 77 | /*buscamos el lnodo que corresponde al idt en la lista y creamos un cnodo en la cola correspondiente*/ | |
| 78 | } | |
| 79 | ind=0; | |
| 80 | - | //vaciar arreglo |
| 80 | + | //vaciar arreglo pala |
| 81 | } | |
| 82 | else if (opcion=="\n"){
| |
| 83 | ind=0; | |
| 84 | - | //vaciar arreglo |
| 84 | + | //vaciar arreglo pala |
| 85 | continue; | |
| 86 | } | |
| 87 | if (dia==6){
| |
| 88 | FILE *proveedor; | |
| 89 | proveedor=fopen("proveedor.dat","r");
| |
| 90 | //agrega items, similar a inicial.dat | |
| 91 | //no entiendo la manera de implementar los * del texto | |
| 92 | fclose(proveedor);} | |
| 93 | if (dia==7){
| |
| 94 | FILE *output; | |
| 95 | output=fopen("output.dat","w");
| |
| 96 | //esta parte aun no la pienso muy bien xDD | |
| 97 | fclose(output); | |
| 98 | dia=0;} | |
| 99 | } | |
| 100 | fclose(input); | |
| 101 | return 0; | |
| 102 | } |