Hello! I am making a program that takes the user's family names, their ages, and where they live. At the end I will be eventually averaging out their age and also printing the names of anyone who lives in Kansas.
I can't seem to get the Kansas part to work properly though.. When I execute the code, everything else works perfectly, but the Kansas part doesn't even print. I'm not sure exactly what I'm doing wrong. Is there something different I need to do when strings are involved rather than integers/floats? Thanks in advance!
Code:
#include <stdio.h>
int main ()
{
/* variable definition: */
char familyMember[60], familyMemberName[60], state[20], stateData[20];
float userFinished=1, age, ageData[5];
int count=0, count2=0, i, j;
// Input Data
while (userFinished > 0)
{
printf("Enter family member:\n");
scanf("%s", &familyMember);
printf("Enter age of family member:\n");
scanf("%f", &age);
ageData[count]=age;
count=count+1;
printf("Enter the state where they live:\n");
scanf("%s", &state);
if (state=="Texas" || state=="texas")
{
familyMemberName[count2];
count2= count2 + 1;
}
printf("Would you like to continue entering names? Enter 1 for yes, and 0 for no\n");
scanf("%d", &userFinished);
}
// Print data
for (j=0; j<count; j++)
printf ("The age of your family is %f\n", ageData[j]);
for (i=0; i<count2; i++)
printf ("Family member %s was born in Texas!\n", familyMemberName[i]);
return 0;
}