There is a program of registrations that I have to make, I put the registration options and so on. All the code is saved in the vectors and they are as expected, but when I return to main()
, it returns to number 1, since I had to initialize it in the first lines of the case.
I want to know some ways where I can continue from the last point, for example, I closed 10 registers, I return to the menu to perform other actions, but when I return to the customer registration option, I want it to continue from the last one ( 11 and etc.). Case 1.
int main(void) {
//Variaveis
int opcao;
clientes cadastro[100];
int i;
char sair_cad;
//Codigo
printf("\n\n1 - Cadastrar Novo Cliente\n");
printf("2 - Cliente\n");
printf("3 - Alterar Cliente\n");
printf("4 - Excluir Cliente\n");
printf("5 - Cadastrar Automovel\n");
printf("6 - Automovel\n");
printf("7 - Alterar Automovel\n");
printf("8 - Excluir Automovel\n");
printf("9 - Locacao\n");
printf("\n Selecione uma opcao por favor: ");
scanf("%d", &opcao);
getchar();
switch (opcao)
{
case 1: // Codigo do Cadastro de Clientes
i = 1;
do
{
system("cls");
cadastro[i].codigo_cliente = i;
printf("\n\nCodigo do cliente: %d", i);
printf("\nNome: ");
scanf("%[^\n]s", &cadastro[i].nome);
setbuf(stdin, NULL);
printf("RG: ");
scanf("%s", &cadastro[i].rg);
setbuf(stdin, NULL);
printf("CPF: ");
scanf("%s", &cadastro[i].cpf);
setbuf(stdin, NULL);
printf("Endereco: ");
scanf("%[^\n]s", &cadastro[i].endereco);
setbuf(stdin, NULL);
printf("Data de Nascimento: ");
scanf("%s", &cadastro[i].data_nasc);
setbuf(stdin, NULL);
printf("Registro Habilitacao: ");
scanf("%s", &cadastro[i].registo_habilitacao);
setbuf(stdin, NULL);
getchar();
system("cls");
printf("\n\n\t\t\t\tCadastro Salvo com Sucesso!");
printf("\n\n Deseja realizar outro cadastro: S/N ?: ");
scanf("%c", &sair_cad);
setbuf(stdin, NULL);
i = i + 1;
} while (sair_cad != 'n');
system("cls");
return main();