/* t2f.c - program to convert text file to binary file for tdp */ #include #include "ffp.h" #define MAXLINE 80 main(argc,argv) char *argv[]; int argc; { int i, nx, ny, debug; char line[80]; FFP zd; FILE *f_in, *f_out, *fopen(); if (argc<4) { printf("usage: t2f nx ny file"); printf(" where nx(ny) is the number of columns(rows) in the data"); printf(" array to be written. 'file' is the name of a text file"); printf(" containing nx*ny lines. The lines must start with a"); printf(" number (which is the data to be written in binary)\n"); exit(1); } debug = argc>4; nx = atoi(argv[1]); ny = atoi(argv[2]); f_in= fopen(argv[3],"r"); if (!f_in) {printf("can't open input file\n"); exit(1);} f_out = fopen("t2f.out","w"); if (!f_out) {printf("can't open output file\n"); exit(1);} (void)fwrite((char *)&nx,4,1,f_out); (void)fwrite((char *)&ny,4,1,f_out); if (debug) printf("%d\t%d\n", nx, ny); for (i=0; i