0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int validaTipo(char t);
typedef union{
struct contratoIndividual{
unsigned int idContrato;
char cpf[14];
char nome[50]; //Nome completo
int idade;
float renda;
}contI;
struct contratoColetivo{
unsigned int idContrato;
char cnpj[18];
char razaoSocial[30];
int quantEmpregMasc;
int quantEmpregFem;
int quantDepen;
float rendaMedia;
}contC;
}uniao;
int main(void){
uniao u;
char tipo;
printf("Tipo de Contrato: [I/C] ");
scanf("%c", &tipo);
printf("%c", tipo);
if (validaTipo(tipo)){
printf("Certinho!");
}
else{
printf("Erradnho");
}
return 1;
}
int validaTipo(char t){
char tipos[3] = {'I', 'i', 'C', 'c'};
for(int i = 0; i < 3; i++){
if(!strcmp(tipos[i], t)){
return 1;
}
}
return 0;
}
Please Haryel, put the code and not the image.
– Daniel Mendes
Be more descriptive in your question and problem. Just playing a 50-line code and saying "Targeting failure" is too vague.
– Isac