title: Program isn't working due to unknown reference error
body: <p>I have created this program. However it isnt working. It shows undefined reference errors for all the functions after the mt(void) function in switch case in main. Where am i wrong?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  void mt(void);
  void prd(void);
  void dry(void);
  void cng(void);
  void nf(void);
  
  struct grocery
  {
      char cat;
  };
  struct meat
  {
      char name1[20];
      int cost1;
      char typ;
      int pckgm;
      int pckyr;
      int expyr;
      int expm;
  } m1;
  
  struct produce
  {
      char name2[20];
      int cost2;
      char typ2;
      int recd;
      int recm;
  } p1;
  
  struct dairy
  {
      char name3[20];
      int cost3;
      int month;
      int date;
  } d1;
  
  struct cg
  {
      char name4[20];
      int cost4;
      int expimon;
      int expiday;
      int aislenum;
      char aisleside;
  } cg1;
  
  struct non
  {
      char name5[20];
      int cost5;
      char categ;
      int anum;
      char aside;
  } n1;
  
  int main()
  {
      struct grocery g1;
      printf("Enter Category:");
      scanf(" %c",&amp;g1.cat);
      switch(g1.cat)
      {
          case 'M':
              mt();
              break;
  
          case 'P':
              prd();
              break;
  
          case 'D':
              dry();
              break;
  
          case 'C':
              cng();
              break;
  
          case 'N':
              nf();
              break;
  
          default:
              printf("Invalid");
              main();
  
      }
      return 0;
  }
  
  void mt(void)
  {
      printf("Enter Category of Meat:");
      scanf(" %c",&amp;m1.typ);
      switch(m1.typ)
      {
          case 'R':
              printf("Enter Name of item:");
              scanf("%s",&amp;m1.name1[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;m1.cost1);
              printf("Enter Packaging Month:");
              scanf("%d",&amp;m1.pckgm);
              printf("Enter Packaging Year:");
              scanf("%d",&amp;m1.pckyr);
              printf("Enter Expiry Month:");
              scanf("%d",&amp;m1.expm);
              printf("Enter Expiry Year:");
              scanf("%d",&amp;m1.expyr);
              printf("Red Meat cost %d cents, packaged in %d %d, expires in %d %d.",m1.cost1,m1.pckgm,m1.pckyr,m1.expm,m1.expyr);
              break;
  
          case 'P':
              printf("Enter Name of item:");
              scanf("%s",&amp;m1.name1[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;m1.cost1);
              printf("Enter Packaging Month:");
              scanf("%d",&amp;m1.pckgm);
              printf("Enter Packaging Year:");
              scanf("%d",&amp;m1.pckyr);
              printf("Enter Expiry Month:");
              scanf("%d",&amp;m1.expm);
              printf("Enter Expiry Year:");
              scanf("%d",&amp;m1.expyr);
              printf("Poultry Meat cost %d cents, packaged in %d %d, expires in %d %d.",m1.cost1,m1.pckgm,m1.pckyr,m1.expm,m1.expyr);
              break;
  
          case 'F':
              printf("Enter Name of item:");
              scanf("%s",&amp;m1.name1[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;m1.cost1);
              printf("Enter Packaging Month:");
              scanf("%d",&amp;m1.pckgm);
              printf("Enter Packaging Year:");
              scanf("%d",&amp;m1.pckyr);
              printf("Enter Expiry Month:");
              scanf("%d",&amp;m1.expm);
              printf("Enter Expiry Year:");
              scanf("%d",&amp;m1.expyr);
              printf("Fish Meat cost %d cents, packaged in %d %d, expires in %d     %d.",m1.cost1,m1.pckgm,m1.pckyr,m1.expm,m1.expyr);
              break;
  
          default:
              printf("Invalid");
              mt();
  }
  
  void prd(void)
  {
      printf("Enter Category:");
      scanf("%c",&amp;p1.typ2);
      switch(p1.typ2)
      {
          case 'F':
          printf("Enter Name of item:");
          scanf("%s",&amp;p1.name2[20]);
          printf("Enter Cost:");
          scanf("%d",&amp;p1.cost2);
          printf("Enter Receiving Month:");
          scanf("%d",&amp;p1.recm);
          printf("Enter Receiving Day:");
          scanf("%d",&amp;p1.recd);
          printf("Fruit cost %d cents,received on %d %d",p1.cost2,p1.recd,p1.recm);
          break;
  
          case 'V':
          printf("Enter Name of item:");
          scanf("%s",&amp;p1.name2[20]);
          printf("Enter Cost:");
          scanf("%d",&amp;p1.cost2);
          printf("Enter Receiving Month:");
          scanf("%d",&amp;p1.recm);
          printf("Enter Receiving Day:");
          scanf("%d",&amp;p1.recd);
          printf("Vegetable cost %d cents,received on %d %d",p1.cost2,p1.recd,p1.recm);
          break;
  
          default:
          printf("Invalid");
          prd();  
      }
  }
  
  void dry(void)
  {
      printf("Enter Name:");
      scanf("%s",&amp;d1.name3[20]);
      printf("Enter Cost:");
      scanf("%d",&amp;d1.cost3);
      printf("Enter Expiration Day:");
      scanf("%d",&amp;d1.date);
      printf("Enter Expiration Month:");
      scanf("%d",&amp;d1.month);
      printf("Dairy cost %d cents, expires on %d %d",d1.cost3,d1.date,d1.month);
  }
  
  void cng(void)
  {
      printf("Enter Name:");
      scanf("%s",&amp;cg1.name4[20]);
      printf("Enter Cost:");
      scanf("%d",&amp;cg1.cost4);
      printf("Enter Expiration Date:");
      scanf("%d",&amp;cg1.expiday);
      printf("Enter Expiration Month:");
      scanf("%d",&amp;cg1.expimon);
      printf("Enter Aisle Number:");
      scanf("%d",&amp;cg1.aislenum);
      printf("Enter Aisle Side:");
       scanf(" %c",&amp;cg1.aisleside);
       printf("canned cost %d cents, expires on %d %d, displayed in aisle %d
       %c",cg1.cost4,cg1.expiday,cg1.expimon,cg1.aislenum,cg1.aisleside);
  
  }
  
  void nf(void)
  {
      printf("Enter Category:");
      scanf(" %c",&amp;n1.categ);
      switch(n1.categ)
      {
          case 'C':
              printf("Enter Name:");
              scanf("%s",&amp;n1.name5[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;n1.cost5);
              printf("Enter Aisle Number:");
              scanf("%d",&amp;n1.anum);
              printf("Enter Aisle Side:");
              scanf("%c",&amp;n1.aside);
              printf("Cleaning Product cost %d cents, placed on aisle %d %c",n1.cost5,n1.anum,n1.aside);
              break;
  
          case 'P':
              printf("Enter Name:");
              scanf("%s",&amp;n1.name5[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;n1.cost5);
              printf("Enter Aisle Number:");
              scanf("%d",&amp;n1.anum);
              printf("Enter Aisle Side:");
              scanf("%c",&amp;n1.aside);
              printf("Pharmacy Product cost %d cents, placed on aisle %d %c",n1.cost5,n1.anum,n1.aside);
              break;
  
          case 'O':
              printf("Enter Name:");
              scanf("%s",&amp;n1.name5[20]);
              printf("Enter Cost:");
              scanf("%d",&amp;n1.cost5);
              printf("Enter Aisle Number:");
              scanf("%d",&amp;n1.anum);
              printf("Enter Aisle Side:");
              scanf("%c",&amp;n1.aside);
              printf("Other Product cost %d cents, placed on aisle %d %c",n1.cost5,n1.anum,n1.aside);
              break;
  
          default:
              printf("Invalid");
              nf();
      }
  }
  </code></pre>
  
  <p>It works only for the first function i.e mt(void). Other than that all the functions are shown to have undefined reference by the compiler.</p>