#include #include #include #include main ( int argc, char *argv[] ) { FILE *asc; CHBookFile hookFile ("asciintuple.dat") ; FILE *names; // names of variables CHBookTupple *NT; double vector[513]; int the_switch = 0; // are there options? char* argument; // the option (if exist) char* AsciiString = (char*) malloc (500 * sizeof (char)); char* begin = (char*) malloc (500 * sizeof (char)); char *end = (char*) malloc (500 * sizeof (char)); int counter; // Error proceeding if (argc < 3) printf ("Usage : asciint [options]\n"); if (argc > 4) { printf ("Error: too many arguments\n"); exit (1); } if (! (asc = fopen (argv[1], "r") ) ) { printf ("Error: source file not found\n"); exit (1); } if ( ! (nt = fopen (argv[2], "r") ) ) { printf ( "Error: unable to open variable name file\n"); exit (1); } // opening the NTuple NT = new CHBookTuple (ntuple.dat); counter = 0; while (fgets (begin, 514, names) ) { while ( end = strstr (begin, " ") ) { *end++ = '\0'; NT << *begin; while (isspace (*end)) end++; begin = end; } NT << *begin; } while ( fgets (begin, 514, asc) ) { while ( end = strstr (begin, " ") ) { *end++ = '\0'; vector [counter++] = atof (begin); begin = end; } if (*begin != '$') { vector [counter++] = atof (begin); NT->fill (vector); } } fclose (asc); fclose (nt); }