1
There is a registration program that I must perform, I put the registration options and etc. All the code is saved in the vectors and are as expected, but when I return to main()
, it goes back to number 1, because I had to initialize it in the first lines of the case.
I want to know some paths where I can continue from the last point, for example, I closed 10 entries, return to the menu to perform other actions, but when I return the option of customer registration, I want it to continue from the last (11 and etc). Block of 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();
return main()
? It’s infinite recursive your code?– Jefferson Quesado
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero