this program has information about customers. this program has to perform the following functions.
- display list of all customers
- search by name
- search by id
- display list of customers having credit limit above 5000
- add new customers

i am unable to compile the program. here are the codes. can anyone fix it?

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define MAX=999
int i;
int id;

struct customer {
 char custID[20];
 char name[50];
 char address[80];
 char tell[15];
 float credl; 
};
int add_Name ();
int menu_Display ();
int get_Menu ();
int get_Option ();
int cust_id();
 int cust_Name();


int main()
{
    
    menu_Display ();
    get_Menu ();
    get_Option ();
    
    getch();
 return 0;
 
}
int menu_Display () {
     int choice=0;
     while (choice!=6) {
           get_Menu ();
           choice = get_Option();
           }}
int get_Menu (){
    int i;
    for (i=0; i<1; i++) {
    printf ("\t1. Display information of all customers\n\n");
    printf ("\t2. Search for customer by Name\n\n");
    printf ("\t3. Search for customer by ID\n\n");
    printf ("\t4. Display a list of customers having credit limit above 5,000\n\n");
    printf ("\t5. Add new customer\n\n");
    printf ("\t6. Exit\n\n");
}
    
}
int get_Option () {
    
    int option;
    printf ("Please enter your option...");
    scanf ("%d", &option);
}
int menu_Option (int option) {
    int i;
    switch (option) {
           case 1 : cust_Name();
           break;
           case 2 : cust_id();
           break;
           case 3 : add_Name();
           break;
           case 6 : printf("The program will now exit\n");
           break;
           default : printf ("Sorry that does not exist");
           i=getchar();
           break;
           }
           }


int add_Name () {
 int i;
 struct customer xrecord[200];
 for (i=0;i<1;i++)
 {
  strcpy(xrecord[i].custID,"ID00");
  //strcpy(xrecord[i].custID,(strcat(xrecord[i].custID,i));
  printf("Enter Name:");
  scanf("\n%s",&(xrecord[i].name)) ;
  printf("Enter address:");
  printf ("\n");
  scanf("\n%s",&(xrecord[i].address));
  printf("Enter tell:");
  scanf("\n%s",&(xrecord[i].tell));
  printf("Enter credl:"); 
  scanf("\n%f",&(xrecord[i].credl));
  
}
  
 }
 int cust_Name() {
    int match;
    int i;
    int result;
    int loop=0;
    char name[20];
    
    printf("Please enter the name which you are searching for\n");
    gets(name);
    while (match == 0 && i < MAX) {
          result= strcmp(all_names[loop].name,name);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found\n");
                   }
          i=getchar();
          }
 int cust_id() {
    int match;
    int i;
    int result=0;
    int loop=0;
    int id;
    
    printf ("Please enter the id number which you are searching for\n");
    scanf ("%d", &id);
    while (match == 0 && i< MAX) {
          result = strcmp (all_names[loop].id,id);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found");
                   }
          i = getchar();
          }
#define MAX 999   (no equals)

And you create all_names out of nowhere in two of your functions

It doesn't really matter _that_ much, but this is more of a C program than a C++ one :)

Edited 7 Years Ago by jonsca: n/a

this is the question

a software company has requested you to implement a customer information system that will keep
up to a maximum of 200 customer data. the customer information to be kept is
1. customer ID[20]
2. Name[50]
3. address[80]
4. telephone number[15]
5. credit limit

yor are requird to develop a c program that has a customer structure and an arra called customers.
the customer information system allows the user to
a. insert new customer using the sequential id.
b. search for a particular customer by ID.
c. search for a particular customer by name.
d. display a list of all customrers.
e. display a list of all customers having a credit limit above 5000


---- this is the code i wrote..i want fix this.. can neone help me plxxxxx

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define MAX=999
int i;
int id;

struct customer {
 char custID[20];
 char name[50];
 char address[80];
 char tell[15];
 float credl; 
};
int add_Name ();
int menu_Display ();
int get_Menu ();
int get_Option ();
int cust_id();
 int cust_Name();


int main()
{
    
    menu_Display ();
    get_Menu ();
    get_Option ();
    
    getch();
 return 0;
 
}
int menu_Display () {
     int choice=0;
     while (choice!=6) {
           get_Menu ();
           choice = get_Option();
           }}
int get_Menu (){
    int i;
    for (i=0; i<1; i++) {
    printf ("\t1. Display information of all customers\n\n");
    printf ("\t2. Search for customer by Name\n\n");
    printf ("\t3. Search for customer by ID\n\n");
    printf ("\t4. Display a list of customers having credit limit above 5,000\n\n");
    printf ("\t5. Add new customer\n\n");
    printf ("\t6. Exit\n\n");
}
    
}
int get_Option () {
    
    int option;
    printf ("Please enter your option...");
    scanf ("%d", &option);
}
int menu_Option (int option) {
    int i;
    switch (option) {
           case 1 : cust_Name();
           break;
           case 2 : cust_id();
           break;
           case 3 : add_Name();
           break;
           case 6 : printf("The program will now exit\n");
           break;
           default : printf ("Sorry that does not exist");
           i=getchar();
           break;
           }
           }


int add_Name () {
 int i;
 struct customer xrecord[200];
 for (i=0;i<1;i++)
 {
  strcpy(xrecord[i].custID,"ID00");
  //strcpy(xrecord[i].custID,(strcat(xrecord[i].custID,i));
  printf("Enter Name:");
  scanf("\n%s",&(xrecord[i].name)) ;
  printf("Enter address:");
  printf ("\n");
  scanf("\n%s",&(xrecord[i].address));
  printf("Enter tell:");
  scanf("\n%s",&(xrecord[i].tell));
  printf("Enter credl:"); 
  scanf("\n%f",&(xrecord[i].credl));
  
}
  
 }
 int cust_Name() {
    int match;
    int i;
    int result;
    int loop=0;
    char name[20];
    
    printf("Please enter the name which you are searching for\n");
    gets(name);
    while (match == 0 && i < MAX) {
          result= strcmp(all_names[loop].name,name);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found\n");
                   }
          i=getchar();
          }
 int cust_id() {
    int match;
    int i;
    int result=0;
    int loop=0;
    int id;
    
    printf ("Please enter the id number which you are searching for\n");
    scanf ("%d", &id);
    while (match == 0 && i< MAX) {
          result = strcmp (all_names[loop].id,id);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found");
                   }
          i = getchar();
          }

Edited 7 Years Ago by Nick Evan: to correct mistake

Again where is all_names coming from it's not anywhere in your code, that's the main thing that stands in the way of it compiling.

This article has been dead for over six months. Start a new discussion instead.