Created
November 26, 2013 01:45
-
-
Save lacytimlick/7652177 to your computer and use it in GitHub Desktop.
So the program is a simple address book that allows the user to input 10 contacts the point of it is when I enter OR for example it would display the contacts that have OR as their state...I have got the inputs working just fine (using structures and a for loop) and also have it so it displays all the contacts that have been entered (for debuggi…
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 counter; | |
char statecode; | |
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("Enter 2-character state code:"); | |
scanf("%s",&statecode); | |
for (counter = 0;counter < size; counter++){ | |
printf("\n\t=============================================================\t\n"); | |
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); | |
} | |
system("\nPAUSE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment