//Reverse.C
{
  FILE *pInp = fopen("ADS.txt", "rt");
  FILE *pOut = fopen("Diss.txt", "wt");
  char szBuf[256];
  char szLastName[256];
  char szInitials[256];
  char *p, *p1;
  char c;
  int iCnt;
  
  for (;;)
  {
    p = szBuf;
    for (;;)
    {
      iCnt = fscanf(pInp, "%c", &c);
      if (iCnt != 1 || c == ',')
        break;
      *p++ = c;
    }
    *p = 0;
    
    //printf("%s\n", szBuf);
    p = szBuf;
    p1 = szLastName;
    
    while (*p == ' ' || *p == '\n') p++;
    while (*p != ' ' && *p != '\n' && *p != 0) *p1++ = *p++;
    *p1 = 0;
    //printf("%s\n", szLastName);
    
    if (*p == 0)
    {
      strcpy(szInitials, "");
    }
    else
    {
      p1 = szInitials;
      while (*p == ' ' || *p == '\n') p++;
      while (*p != 0) *p1++ = *p++;
      *p1 = 0;
    }
    //printf("%s\n", szInitials);
    
    fprintf(pOut, "%s %s, ", szInitials, szLastName);
    printf(        "%s %s, ", szInitials, szLastName);
    
    if (iCnt != 1)
    {
      break;
    }
  }
  fprintf(pOut, "\n");
  printf("\n");
  
  fclose(pInp);
  fclose(pOut);
}
