#include #include #include #include #include "sac.h" /* cc readsac.c -g -o readsac -lm*/ /* Template for c codes that use sac files. This just reads in a sac file, copies the array, and writes it out into a new sac file. We #include several header files that aren't needed but might be when the template is modified. */ main(int argc, char* argv[]) { FILE *sacfile; struct sac head; char insacfile[256]; char outsacfile[256]; float indata[150000], outdata[150000]; int i; if (argc != 3) { (void) printf("Usage:%s insacfile outsacfile \n",argv[0]); return 1; } else { (void) strcpy(insacfile,&argv[1][0]); (void) strcpy(outsacfile,&argv[2][0]); (void) printf("infile %s, outfile %s\n",insacfile,outsacfile); } /* Read sac file */ sacfile = fopen(insacfile,"r"); (void) fread(&head, 1 , sizeof(head), sacfile); (void) fread( indata, sizeof(float), head.npts, sacfile); (void) fclose(sacfile); /* Set out data points to in data points. */ for (i=0;i