It is intended that it builds a program that allows the management of reservations of a
show room with registration of event name, date, time, duration and customer name.
1) It should include:
a) The program should be structured using modular programming, whenever
this is applicable (functions and procedures);
b) Comments and parameters;
c) At least one text file;
d) A control that verifies that the files already exist in the disk and message in case
of error;
e) Allow the insertion, consultation and modification of the data of the files;
f) Contain a menu system that allows navigation throughout the project;
g) Allow to search and query the data of the file by a field (for example by
date).
h) Allow the last record to be displayed on the monitor.
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.
We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
struct registro { //estrutura do registro
char nomeevento[40];
char nome[40];
char data[20];
char hora[20];
char duracao[40];
char status;
} reg;
char url[]="gestaoderesrvas.txt";
FILE *fp;
void criar()
{
fp=fopen(url, "w");
if(fp==NULL)
{
cout<<"Ficheiro não existe"<<endl;
}else
do
{
printf("\n Digite o nome do evento ou <FIM> para sair:\n\n");
cin.ignore();
gets(reg.nomeevento);
if (((reg.nomeevento,"fim")!=0)&&((reg.nomeevento,"FIM")!=0)){
printf("\n Nome do cliente:"); gets(reg.nome);
printf("\n Data:"); gets(reg.data);
printf("\n Hora:"); gets(reg.hora);
printf("\n Duração:"); gets(reg.duracao);
printf("\n Erro de gravação!!");
}
else
{ printf("\n Gravação feita com sucesso...\n\n");}
}while(((reg.nomeevento,"fim")!=0)&&((reg.nomeevento,"FIM")!=0));
fclose(fp);
}
void sobre() { //Diz ao utilizador por quem foi feito o programa
printf("\n\n");
printf("\t########################################################\n");
printf("\t# Programa feito por.: gheorghe #\n");
printf("\t########################################################\n\n\n");
printf("\t\t\tTecle <ENTER> para voltar");
}
void busca()
{
int achou=-1,posicao=0;
char datap[40];
{
fp=fopen(url, "w");
if(fp==NULL)
cout<<"Ficheiro não existe"<<endl;
}
printf("\nDigite a data a ser procurada:");
gets(datap);
rewind(fp);
while((!feof(fp))&&(achou==-1))
{
if (!feof(fp))
{if ((datap, reg.data)==0)
{if (reg.status=='0')
{posicao=-2;}
achou=1;
}
else{posicao++;}
}
else{posicao=-1;}
}
if (achou==-1)
{posicao=-1;}
fclose(fp);
cout<<posicao;
}
void alterar(void){
int pos;
if (pos==-1)
{
printf("\nNome inexistente no arquivo");
}
else if(pos==-2)
{
printf("\nNome inexistente no arquivo!");
It looks like this is mostly using C strings. I'll assume that's required, but if it isn't, you'd be much better off using C++ strings instead.
Use strcmp() to compare strings. \ isn't a valid escape sequence.
At the beginning of alterar(), you use pos before it's initialized. I've left that bug in because I'm not sure what you need.
This version compiles and should help you get further: