Here's my code:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #define MAX_CONTACT 100 // maximum number of contacts
- #define MAX_FIELDLEN 50 // maximum length of a field string
- #define MAX_LINELEN 250 // maimum length of a user-input line
- #define RETURN '\n'
- char name[MAX_CONTACT][MAX_FIELDLEN];
- char telephone[MAX_CONTACT][MAX_FIELDLEN];
- char address[MAX_CONTACT][MAX_FIELDLEN];
- char city[MAX_CONTACT][MAX_FIELDLEN];
- char state[MAX_CONTACT][MAX_FIELDLEN];
- char zipcode[MAX_CONTACT][MAX_FIELDLEN];
- char email[MAX_CONTACT][MAX_FIELDLEN];
- char input[MAX_FIELDLEN];
- void exit();
- int read_line();
- main(){
- int count,character,file;
- int i;
- char c;
- character=0;
- file = 0;
- while (( c = getchar()) != EOF){
- ..... //Takes in the input from the file
- }
- while ((input[0] !='q') && (input[0] !='u') && (input[0] !='i') && (input[0] !='t')){
- printf("\n\n-----Address Book-----\n");
- printf("\n");
- printf("----Search Record-----\n");
- printf("----Insert Record-----\n");
- printf("----Delete Record-----\n");
- printf("--Review All Records--\n");
- printf("---------Quit---------\n");
- count=0;
- while((c=getchar())!= RETURN){ --------------------------- I am having trouble here
- input[count++]=c;------------------------------where the user is supposed to
- }---------------------------------------------------------------------------- input data
- for (i=0;i<count;i++){
- printf("%c",input[count]);
- }
- if (input[0]=='x'){
- exit(0);
- }
- if (((input[0]=='S')||(input[0]=='s')) && (input[1]=='e') && (input[2]=='a') && (input[3]=='r') && (input[4]=='c') && (input[5]=='h')){
- printf("You typed in search records");
- }
- else if (((input[0]=='I')||(input[0]=='i')) && (input[1]=='n') && (input[2]=='s') && (input[3]=='e') && (input[4]=='r') && (input[5]=='t')){
- printf("You typed in insert records");
- }
- else if (((input[0]=='D')||(input[0]=='d')) && (input[1]=='e') && (input[2]=='l') && (input[3]=='e') && (input[4]=='t') && (input[5]=='e')){
- printf("You typed in delete records");
- }
- else if (((input[0]=='R')||(input[0]=='r')) && (input[1]=='e') && (input[2]=='v') && (input[3]=='i') && (input[4]=='e') && (input[5]=='w')){
- printf("You typed in review records");
- }
- }
- printf("You typed in Quit");
- }