-
-
Save nobane/7672733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <string.h> | |
#define size 2 | |
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 () { | |
printf("Program: Structs\nAuthor: Lacy Timlick\n"); | |
struct Customer C1[size]; | |
int printline = 0; | |
int counter; | |
char statecode, | |
*loop = "\nEnter 2-character state code or 'exit' to escape: ", | |
*line = "\n\t=============================================================\t\n"; | |
for (counter = 0;counter < size; counter++) { | |
C1[counter].accountId = counter + 1; | |
printf("\nEnter Data for Customer %d\n", counter + 1); | |
printf("Enter First Last Phone: "); | |
scanf("%s%s%s",&C1[counter].firstName,&C1[counter].lastName,&C1[counter].phone); | |
printf("Enter Address (Street City State ZIP): \n"); | |
scanf("%s%s%s%d",&C1[counter].street,&C1[counter].city,&C1[counter].state,&C1[counter].zip); | |
} | |
printf("%s",loop); | |
scanf("%s",&statecode); | |
while (strcmp(&statecode,"exit") != 0) { | |
for (counter = 0;counter < size; counter++) { | |
if (strcmp(&statecode, C1[counter].state) == 0) { | |
printline = 1; | |
printf("%s",line); | |
printf("\n\tData for Customer %d\t\n", C1[counter].accountId); | |
printf("\tAccount: %d\t\n", C1[counter].accountId); | |
printf("\tName: %s %s\t\n", C1[counter].firstName, C1[counter].lastName); | |
printf("\tAddr: %s %s %s %d\t\n", C1[counter].street, C1[counter].city, C1[counter].state, C1[counter].zip); | |
printf("\tPhone: %s\t\n", C1[counter].phone); | |
} | |
} | |
if (printline) { | |
printline = 0; | |
printf("%s",line); | |
} | |
printf("%s",loop); | |
scanf("%s",&statecode); | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment