Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ingresar //
- //Declaración de función
- int ingresar_notas(WINDOW *barra_superior, WINDOW *barra_mensajes, int *p_marcar_item_seleccionado, FILE **p_arch1, char *p_ruta_arch1, struct notas *p_notas);
- //Apertura del archivo
- *p_arch1= fopen(p_ruta_arch1, "a+b");
- if(*p_arch1 == NULL)
- {
- curs_set(0);
- noecho();
- wprintw(barra_mensajes,"#Error: No se pudo leer el archivo");
- wrefresh(barra_mensajes);
- sleep(2);
- werase(barra_mensajes);
- wrefresh(barra_mensajes);
- delwin(barra_superior);
- delwin(barra_mensajes);
- return(0);
- }
- //Ingreso al archivo
- fseek(*p_arch1, 0, SEEK_END);
- fwrite(p_notas, sizeof(struct notas), 1, *p_arch1);
- //Cerrar archivo
- if(fclose(*p_arch1) != 0)
- {
- curs_set(0);
- noecho();
- wprintw(barra_mensajes,"#Error: No se pudo guardar el archivo");
- wrefresh(barra_mensajes);
- sleep(2);
- werase(barra_mensajes);
- wrefresh(barra_mensajes);
- delwin(barra_superior);
- delwin(barra_mensajes);
- return(0);
- }
- // Buscar //
- //Declaración de función
- int busqueda_notas(WINDOW *barra_superior, WINDOW *barra_mensajes, int *p_marcar_item_seleccionado, FILE **p_arch1, char *p_ruta_arch1, struct notas *p_notas);
- //Ejecución de busqueda
- fseek(*p_arch1, (atoi(selector_registro) - 1)*sizeof(struct notas), SEEK_SET);
- fread(p_notas, sizeof(struct notas), 1, *p_arch1);
- //Cerrar archivo
- if(fclose(*p_arch1) != 0)
- {
- curs_set(0);
- noecho();
- wprintw(barra_mensajes,"#Error: No se pudo guardar el archivo");
- wrefresh(barra_mensajes);
- sleep(2);
- werase(barra_mensajes);
- wrefresh(barra_mensajes);
- delwin(barra_superior);
- delwin(barra_mensajes);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement