while(clients[x].gender != 'm' || clients[x].gender != 'M' || clients[x].gender != 'f' || clients[x].gender != 'F' || clients[x].gender != ' ')
The if statements in the loop just check for equivalency because it gives me errors if I try to assign m or f to the char variable for some reason. So is there way to check if it is not equivalent to m, f, or blank rather than if it is not equal to it because I think that is what the issue is? Here is the whole program:
int main()
{
/* Variable Declarations */
/*-----------------------*/
int number_of_clients;
int x, i;
/* Information struct declaration */
typedef struct
{
char name[35];
char address[50];
char city[25];
char state[3];
long int zip_code;
int age;
char gender;
char client_gender[50];
}Information;
Information clients[10];
printf("Welcome to the Client Information Program!\n\n");
/* Begin do loop */
do
{
printf("Enter the number of clients(1-10): "); /* Prompts for the number of employees */
scanf("%i", &number_of_clients);
fflush(stdin);
if(number_of_clients < 1 || number_of_clients > 10) /* Ensures the number of employees is between 1 and 10 */
{ /* or else displays error and re-prompts */
printf("\nError: Number of employees must be between 1 and 10, please re-enter!\n\n");
}
}while(number_of_clients < 1 || number_of_clients > 10); /* End do loop */
for(x = 0; x < number_of_clients; x++)
{
printf("Enter name: ");
gets(clients[x].name);
printf("Enter street address: ");
gets(clients[x].address);
printf("Enter city: ");
gets(clients[x].city);
printf("Enter state: ");
scanf("%s", &clients[x].state);
fflush(stdin);
do
{
printf("Enter zip code: ");
scanf("%ld", &clients[x].zip_code);
fflush(stdin);
if(clients[x].zip_code < 00001 || clients[x].zip_code > 99999)
{
printf("Error: Zip code must be between 00001 and 99999, please re-enter!");
}
}while(clients[x].zip_code < 00001 || clients[x].zip_code > 99999);
do
{
printf("Enter age: ");
scanf("%i", &clients[x].age);
fflush(stdin);
if(clients[x].age < 1 || clients[x].age > 120)
{
printf("Error: Age must be between 1 and 120, please re-enter!");
}
}while(clients[x].age < 1 || clients[x].age > 120);
do
{
printf("Enter gender (M or F): ");
scanf("%s", &clients[x].gender);
fflush(stdin);
if(clients[x].gender == 'm' || clients[x].gender == 'M')
{
clients[x].client_gender == "He is %i years old.", clients[x].age;
}
else if(clients[x].gender == 'f' || clients[x].gender == 'F')
{
clients[x].client_gender == "She is %i years old.", clients[x].age;
}
else if(clients[x].gender == ' ')
{
clients[x].client_gender == "Age is %i years old.", clients[x].age;
}
else
{
printf("Error: Gender must be M, F, or blank, please re-enter!");
}
}while(clients[x].gender != 'm' || clients[x].gender != 'M' || clients[x].gender != 'f' || clients[x].gender != 'F' || clients[x].gender != ' ');
}
printf("The information you entered is:\n");
for(i = 0; i < number_of_clients; i++)
{
printf(clients[x].name);
printf(clients[x].address);
printf("%s, %s %.5ld", clients[x].city, clients[x].state, clients[x].zip_code);
printf(clients[x].client_gender);
}
}

New Topic/Question
Reply



MultiQuote



|