Here I'm just making a little and simple database.
Currently written code vv.
#include <stdio.h>
struct Customer{
char firstName[30];
char lastName[30];
char street[35];
char city[20];
char state[3];
int zip;
char phone[15];
int accountId;
};
int main()
{
int size=1;// this number can be changed though would recommend leaving on 3 or something like that for quick testing
struct Customer s[size];
{
int Count;
for(Count=0; Count < size;Count++)
{
printf("Enter Data for Customer %i\n",Count);
printf("Enter First Last Phone: ");
scanf("%s %s %s",s[Count].firstName,s[Count].lastName,s[Count].phone);
printf("Enter Address (Street City State ZIP): ");
scanf("%s %s %s %d",s[Count].street,s[Count].city,s[Count].state,&s[Count].zip);
printf("\n");
}
}
char locstate[3];
int fail=0;
char checkstate[3];
int check;
int check2;
printf("which state would you like to locate customers in:");
scanf("%s",locstate);
for(check=0;check < size;check++)
{
{
checkstate=s[check].state;
//printf("%s",checkstate);
if(locstate==checkstate)
{
printf("data for Customer %i",check);
printf("Account: %i",check);
printf("name: %s %s",s[check].firstName,s[check].lastName);
printf("addr: %s %s %s %d",s[check].street,s[check].city,s[check].state,s[check].zip);
}
else
{
fail=fail+1;
}
}
}
if(fail==size)
{
printf("there was no one in that state.");
}
else
{
return(0);
}
}
and if I instead remove the check state codes and try to directly compare locate to s.[check].state the if statement always fails regardless if both locstate and s.[check].state have received teh same variable form the user.