#include #include #include #include #include int main(int argc, char *argv[]) { int c; char filename[1024]; FILE *outfile; int i, j, k; int factor; if (argc < 4) { printf("usage: %s -o -c #\n", argv[0]); return 1; } while (1) { int option_index = 0; static struct option long_options[] = { { 0, 0, 0, 0 } }; c = getopt_long(argc, argv, "c:o:", long_options, &option_index); if (c == -1) { break; } switch (c) { case 0: break; case 'c': factor = atoi(optarg); break; case 'o': strcpy(filename, optarg); break; defaults: return 2; } } strcat(filename, "/file.out"); outfile = fopen(filename, "w"); if (outfile == NULL) { printf("cannot open %s\n", filename); return 3; } for (i = 0; i < factor; i++) { for (j = 0; j < 10; j++) { for (k = 0; k < 3000; k++) { fprintf(outfile, "%d %d %d\n", i, j, k); } } } fclose(outfile); return 0; }