#include main() { int year, hour, tflag, fileN=1, lineN=0; double day, x, y, lat, lon, u, v, p, t; char id[20], string[20]; FILE *out; sprintf(string,"buoy_%d.dat",fileN); out = fopen(string,"w"); do { fscanf(stdin,"%s%d%lf%d%lf%lf%lf%lf%lf%lf%lf%lf%d", id,&year,&day,&hour,&lat,&lon,&x,&y,&u,&v,&p,&t,&tflag); if ( feof( stdin ) ) exit(0); lineN++; fprintf(out, "%s %d %.0lf %d %.5lf %.5lf %.5lf %.5lf %.5lf %.5lf %d\n", id, year, day, hour, lat, lon, u, v, p, t, tflag); if ( lineN >= 18000 ) { fclose(out); lineN = 0; fileN++; sprintf(string,"file%d",fileN); out = fopen(string,"w"); } } while ( 1 ); }