برنامه ای که مشخصات افرادی را گرفته در آرایه ای از ساختمانها قرار می دهد :

عمل درج و حذف نیز انجام می دهد .

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define MAX 100
struct  addr{
    char name[10] ;
    char street[15] ;
    char city[10] ;
    char state[3] ;
    unsigned long int zip;
} addr_info[MAX] ;
void init_list_all(void), enter(void) ;
void delete_e(void);
void list_all(void) ;
int menu_select(void), find_free(void);
int main()
{
   char choice , ch ;
   clrscr();
   init_list_all() ;
   for(;;){
      choice = menu_select() ;
      switch(choice) {
        case 1:  enter();  break ;
        case 2:  delete_e(); break ;
        case 3:  list_all();   break ;
        case 4:  exit(0) ;
      } //end of switch
   }//end of for
}
//****************************
void init_list_all(void)
{
     register int t ;
     for(t = 0 ; t < MAX; ++t)
  addr_info[t].name[0]='\0';
}
//****************************
int menu_select(void)
{
      char s[10] ;
      int c ;
      clrscr() ;
      gotoxy(29, 6);
      printf("1) << enter a name >>");
      gotoxy(29, 8);
      printf("2) << delete_e a name >>");
      gotoxy(29, 10);
      printf("3) << list_all the file >>");
      gotoxy(29, 12);
      printf("4) <<      Quit     >>");
      do {
   gotoxy(24, 15) ;
   printf(" Please enter your choice(1-4):");
   gets(s) ;
   c = atoi(s) ;
      } while(c < 0 || c > 4) ;
      return (c);
}

//****************************
void enter(void)
{
  int slot ;
  char s[80] ;
  slot = find_free() ;
  if(slot == -1) {
 printf("\n list full");
 return ;
  }
  gotoxy(5, 17) ;
  printf("enter name:") ;
  gets(addr_info[slot].name);
  gotoxy(40, 17) ;
  printf("enter street:") ;
  gets(addr_info[slot].street);
  gotoxy(5, 19) ;
  printf("enter city:") ;
  gets(addr_info[slot].city) ;
  gotoxy(40, 19) ;
  printf("enter state code:") ;
  gets(addr_info[slot].state) ;
  gotoxy(22, 21) ;
  printf("enter zip:") ;
  gets(s) ;
  addr_info[slot].zip = strtoul(s,'\0',10) ;
}
//****************************
find_free(void)
{
      register int t ;
      for(t = 0 ; addr_info[t].name[0]
   && t < MAX ; ++t) ;
      if(t == MAX) return -1 ;
     return t ;
}
//****************************
void delete_e(void)
{
      int slot ;
      gotoxy(28, 19) ;
      printf("enter record #(0-99):");
      scanf("%d",&slot) ;
      if(slot >= 0 && slot < MAX)
  addr_info[slot].name[0] = '\0';
}
//****************************
void list_all(void)
{
     register  int t ;
     int r = 0 ;
     char ch ;
     clrscr() ;
     gotoxy(25, 2) ;
     printf(" << all information in list are:>>") ;
     gotoxy(13,3) ;
     printf("**********************");
     printf("*******************") ;
     printf("********************") ;
     gotoxy(10, 4);
     printf("     name      street         city      ");
     printf("  state            zip");
     gotoxy(10, 5);
     printf("   ________    _______      ______     ") ;
     printf("  ______          ____");
     for(t = 0; t < MAX ; ++t) {
 if(addr_info[t].name[0]) {
      gotoxy(14, 6+r) ;
      printf("%s ",addr_info[t].name);
      gotoxy(26, 6+r) ;
      printf("%s ",addr_info[t].street);
      gotoxy(40, 6+r) ;
      printf("%s ",addr_info[t].city);
      gotoxy(54, 6+r) ;
      printf("%s ",addr_info[t].state);
      gotoxy(70, 6+r) ;
      printf("%lu ",addr_info[t].zip);
      r++ ;
 }
     }
     gotoxy(13, 6+r) ;
     printf("********************");
     printf("*********************");
     printf("********************");
     gotoxy(27, 7+r) ;
     printf("press any key to continue");
     getch() ;
}