borrar archivos y estructuras
Publicado por jose alfredo perez (1 intervención) el 06/12/2015 00:59:20
hola amigo, por favor ayúdenme con este programa. necesito dar de alta la música de acuerdo su nombre de la cancion, artista y año. eso ya lo tengo pero necesito daros de baja, es decir borrrarlo, lo he ingado y lo he intentado de mil formas pero simplemente no me sale.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include <windows.h>
void gotoxy(int x,int y){
HANDLE hcon;
hcon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X = x;
dwPos.Y= y;
SetConsoleCursorPosition(hcon,dwPos);
}
struct guardar{
int yea;
char artista[30];
char cancion[30];
};
FILE *discos;
guardar gu;
void altas(){
discos = fopen("discos.gua","a+b");
gotoxy (10,5); printf("CANCION:");
fflush(stdin);
gets(gu.cancion);
gotoxy (10,7);printf("ARTISTA:");
fflush(stdin);
gets(gu.artista);
gotoxy (10,9); printf("A\xA4O:");
scanf("%d",&gu.yea);
fwrite(&gu,sizeof(gu),1,discos);
system("cls");
fclose(discos);
}
void bajas (){
}
void reportes(){
discos = fopen("discos.gua","r+b");
fread(&gu,sizeof(gu),1,discos);
printf("%-25s %-15s %-10s\n\n","NOMBRE DE LA CANCION","ARTISTA","A\xA4O");
while(feof(discos)==0){
printf("%-25s %-15s %-10d\n\n", gu.cancion,gu.artista,gu.yea);
fread(&gu,sizeof(gu),1,discos);
}
fclose(discos);
system("pause");
system("cls");
}
int main(){
int opc;
do{
gotoxy (25,4); printf("ALMACEN DE DISCOS\n");
gotoxy (25,6); printf("1. ALTAS\n");
gotoxy (25,8); printf("2. BAJAS\n");
gotoxy(25,10); printf("3. REPORTES\n");
gotoxy(25,12); printf("4. SALIR\n");
gotoxy(25,14); printf("DAME UNA OPC:");
gotoxy (25,15); scanf("%d",&opc);
system("cls");
switch(opc){
case 1:
altas();
break;
case 2:
bajas();
break;
case 3:
reportes();
break;
case 4:
break;
}
getch();
}while(opc != 4);
return 0;
}
Valora esta pregunta


0