-1
I registered the code of the client and now I need to request again so I need to check whether there is or not registered code, only even if the codes are different or says that there is registered code.
Question: 3 - Calculate the sale value of the vehicle Request: Vehicle plate (check if you have a registered vehicle) Customer code (check if you have a registered customer) The factory value of the vehicle Check if the customer wants to buy the vehicle on demand or on time
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include <string.h>
main (){
char aux[50];
int opcao;
printf("################################");printf("\n# seja bem vindo #");printf("\n# #"); printf("\n################################");
struct cliente
{
char codigo[50];
char nome[50];
char endereco[50];
float salario;
};
struct cliente cadastro;
cadastro.codigo;
cadastro.nome;
cadastro.endereco;
cadastro.salario;
struct veiculo
{
char placa[50];
char marca[50];
char ano[50];
char combustivel[50];
};
struct veiculo cadastro1;
cadastro1.placa;
cadastro1.marca;
cadastro1.ano;
cadastro1.combustivel;
do{
printf("\n1 - Cadastrar Novo Cliente");
printf("\n2 - Cadastro Novo Veiculo");
printf("\n3 - Calcular o Valor Da Venda Do Veiculo");
printf("\n0 - Finalizar\n");
printf(" \nSelecione uma opcao por favor: ");
scanf("%d", &opcao);
fflush(stdin);
if(opcao==1){
system("cls");
printf("#######################################################");printf("\n# Voce selecionou a opcao 1 - Cadastrar Novo Cliente #");printf("\n# #"); printf("\n#######################################################");
printf("\n\nDigite o codigo Para o cliente: ");
gets(cadastro.codigo);
fflush(stdin);
printf("\nDigite o Nome Do Cliente: ");
gets(cadastro.nome);
fflush(stdin);
printf("\nDigite o Endereco Do Cliente: ");
gets(cadastro.endereco);
fflush(stdin);
printf("\nDigite o Salario Do Cliente: ");
scanf("%.2f",cadastro.salario);
printf("\n\n");
fflush(stdin);
printf("\n\nCliente Cadastrado\n\n");
fflush(stdin);
printf(" \nPrecione Enter Para Volta ao Menu Principal.... ");
getchar();
system("cls");
main();
}
else{
system("cls");
if(opcao==2){
printf("#######################################################");printf("\n# Voce selecionou a opcao 2 - Cadastro Novo Veiculo #");printf("\n# #"); printf("\n#######################################################");
fflush(stdin);
printf("\n\nDigite a Placa do veiculo: ");
gets(cadastro1.placa);
fflush(stdin);
printf("\nDigite a Marca Do Veiculo: ");
gets(cadastro1.marca);
fflush(stdin);
printf("\nDigite o Ano Do Veiculo:");
gets(cadastro1.ano);
fflush(stdin);
printf("\nDigite o Tipo de Combustivel: ");
scanf("%c",cadastro1.combustivel);
fflush(stdin);
printf("\n\nVeiculo Cadastrado\n\n");
fflush(stdin);
printf(" \nPrecione Enter Para Volta ao Menu Principal.... ");
getchar();
system("cls");
main();
break;
}
else{
if(opcao==3){
printf("\n\n insira o codigo do cliente");
gets(aux);
if (strcmp(aux,cadastro.codigo))
printf ("\n\n ha codigo cadastrado");
else printf ("\n\ nao ha codigo cadastrado.");
printf(" \nPrecione Enter Para Volta ao Menu Principal.... ");
getchar();
system("cls");
main();
break;
}
}
}
}while (opcao != 9 || opcao < 9);
return 0;
}
then, it seems that strcmp is not pulling the struct string because even with the above mentioned code it did not run , even without registering code it tells how there is code
– Jhonatan Pereira
Strange because I tested it here and it worked normally, and looking I see no more errors related to this excerpt
– Filipe
you can send me your code just the if part to parse ? which compiler is using.
– Jhonatan Pereira
i do not use Windows use linux, compile directly by terminal with gcc, the if ta the same way I put there
– Filipe
Um, without the whirlwind
– Jhonatan Pereira