typedef const char *STRING;
typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t;
typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t;




passwd_t passwd_list[]={
  {, , 1001, 1000, 
    {, , , , },
    , },
  {, , 1002, 1000,
    {, , , , },
    , }
};

main(){

  FILE *passwd_text=fopen(, );
  int rec_num;
  for(rec_num=0; rec_num < sizeof passwd_list/sizeof(passwd_t); rec_num++)
    fprintf(passwd_text, PASSWD_FMT, passwd_list[rec_num]);
  fclose(passwd_text);


  passwd_text=fopen(, );
  char passwd_buf[BUFSIZ]; 
  passwd_t new_rec =
      {, , 1003, 1000, 
          {, , , , },
          , };
  sprintf(passwd_buf, PASSWD_FMT, new_rec);

  write(fileno(passwd_text), passwd_buf, strlen(passwd_buf));
  close(passwd_text);


  passwd_text=fopen(, );
  while(!feof(passwd_text))
    fscanf(passwd_text, , passwd_buf, );
  if(strstr(passwd_buf, ))
    printf(, passwd_buf);
}