Error "expected declaration"
Publicado por Shumaro (2 intervenciones) el 15/10/2020 21:33:11
Al compilar el programa me arroja este error "expected declaration specifiers or ‘...’ before ‘cliente1’", esto para las lineas 25 a la 29
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Cliente
{
char nombre[10];
char apellido[10];
int habitacion;
char fecha[10];
int dias;
char formaPago[10];
char cafeteria[2];
float costo;
}cliente1;
/*struct Ocupadas //Cuartos y disponibilidad
{
char estado[10];
int disp;
int cuarto;
}cuartos[20];*/
int Hotel();
void Ingresar(cliente1 *reg, int *cont);
void DatosResidente(cliente1 * reg, int *cont);
void Actualizar(cliente1 * reg, int cont);
void Borrar(cliente1 * reg, int cont);
void Bucar(cliente1 * reg, int *cont);
int main()
{
int opcion, respuesta, cont_reg =0;
cliente1 *registros = (cliente1 *) malloc(5 * sizeof(cliente1));
do{
system("cls");
opcion = Hotel();
switch(opcion)
{
case 1:
Ingresar(registros, &cont_reg);
break;
case 2:
DatosResidente(registros, cont_reg);
break;
case 3:
Actualizar(registros, cont_reg);
break;
case 4:
Borrar(registros, &cont_reg);
break;
case 5:
Buscar(registros, cont_reg);
break;
case 6:
exit(1);
break;
default:
printf("\nOpcion incorrecta");
break;
}
//do{
printf("\nDesea realizar otra accion?: [1]Si [2]No");
scanf("\n%d",&respuesta);
//}while(respuesta<1 || respuesta <2);
}while(respuesta ==1);
free(registros);
/*
for(n=0;n<20;n++)
{
cuartos[n].disp = 1;
}
//Funcionalidad del hotel
cliente1.costo = 200* cliente1.dias; //costo
printf("Uso la cafeteria?: ");
gets(cliente1.cafeteria);
if(strcmp(cliente1.cafeteria, "si") == 0)
{
cliente1.costo += cliente1.dias*50;
}
*/
}
int Hotel()
{
int opcion;
printf("HOTEL LAS PALMITAS\n");
printf("\n[1] Ingresar datos");
printf("\n[2] Desplegar datos");
printf("\n[3] Actualizar estado");
printf("\n[4] Borrar datos");
printf("\n[5] Buscar cliente");
printf("\n[6] Salir");
printf("\n Seleccione la opcion: ");
scanf("%d",&opcion);
return opcion;
}
void Ingresar(cliente1 * reg, int *cont)
{
char buffer[35];
cliente1 aux;
if((*cont) < 5)
{
printf("Nombre: ");
fflush(stdin);
fgets(aux.nombre, sizeof(buffer),stdin);
printf("Apellido: ");
fflush(stdin);
fgets(aux.apellido, sizeof(buffer),stdin);
reg[*cont] = aux;
++(*cont);
}else
{
printf("\nNo es posible ingresar mas registros");
}
/*
printf("Estado de habitaciones: \n");
for(n=0; n<20; n++) // Imprime el estado de los cuartos
{
printf("\n\tcuarto %2d: %d",n+1, cuartos[n].disp);
}
printf("\nIngrese la habitacion deseada: "); // Pide el cuarto deseado
scanf("%d",&cliente1.habitacion);
if(cuartos[cliente1.habitacion-1].disp == 0)
{
printf("\nEsa habitacion ya esta reservada, seleccione otra: ");
scanf("%d",&cliente1.habitacion);
}
cuartos[cliente1.habitacion-1].disp = 0;
printf("\n");
printf("Fecha: ");
fflush(stdin);
gets(cliente1.fecha);
printf("Dias: ");
scanf("%d",&cliente1.dias);
printf("Forma de pago: ");
fflush(stdin);
gets(cliente1.formaPago);*/
}
void Actualizar(cliente1 * reg, int cont){
}
void Borrar(cliente1 * reg, int *cont){
}
void Buscar(cliente1 * reg, int cont){
}
void DatosResidente(cliente1 * reg, int cont)
{
int n;
if(cont == 0){
printf("\nNo hay datos de clientes");
}else
{
// Imprimir datos
printf("\n\nNombre \t Apellido \t No.Habit \t Fecha \t Dias rest \t Forma de Pago \t Cafeteria \t Costo Total");
printf("\n");
for(n=0;n<cont;n++)
{
printf("%-10s %-10s",reg[n].nombre, reg[n].apellido);
printf("\t %-6d \t %-7s",reg[n].habitacion, reg[n].fecha);
printf("\t %-4d \t %-10s",reg[n].dias, reg[n].formaPago);
printf("\t %-7s \t %-10.2f ",reg[n].cafeteria, reg[n].costo);
printf("\n\n");
}
}
}
Valora esta pregunta


0