#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

main(int argc, char *argv[])

{ FILE *ifp, *ofp;
  char  hold;

  union swp
    { char     b[20];
      long int val[5];
      float    rval[5];
    } buff;

  unsigned long int rec[3];  /* Record values */
  long int rows,cols;
  int i,j,k;
  char *rem;

  if (argc != 4)
    { fprintf (stderr,"Usage: gettab file rows columns\n");
      exit(0);
    }

  if ((ifp = fopen(argv[1],"rb")) == NULL)
    { fprintf (stderr,"Unable to open %s for reading (%s)\n",
               argv[1],strerror(errno));
      exit(100);
    }

  rows = strtol(argv[2],&rem,10);
  cols = strtol(argv[3],&rem,10);

  for (i=0; i<rows; i++)
    { fread((void *)(buff.b),4,cols,ifp);

      for (j=0; j<cols; j++)
        { k = j*4;
          hold = buff.b[k];
          buff.b[k] = buff.b[k+3];
          buff.b[k+3] = hold;
          hold = buff.b[k+1];
          buff.b[k+1] = buff.b[k+2];
          buff.b[k+2] = hold;

          printf("%11d ",buff.val[j]);
        }
      printf ("\n");
    }

  close(ifp);
  close(ofp);

  exit(0);
}