#include "header.h" int main(int argc, char **argv) { int i=0, n=100; char name[n]; //Very large file name security hole. //BE CAREFUL. //A name very much like the "Quake" executable //May be provided. This may result in "Quake" //Not prime numbers. FILE *fOut; time_t start,stop; //I think these are just bigish ints. start = time(NULL); //This collects the first time. if (argc==3 && argv[1][0]!='>' && argv[1][0]!='<') { /*Hohmahgawd. The names of an input and and output file. Accept it!*/ n=atoi(argv[1]); //The first is the number of primes. fOut=fopen(argv[2],"wi+"); //The second, the [overwriten] output } else { //OK, we're accepting from standard in. //Perhaps they've decided to use redirectors. //Anyways, get the array size scanf("%d",&n);//Number of primes to find. scanf("%s",&name);//I needed to stick this in the &name buffer. // printf("%s",name); fOut=fopen(name,"wi+"); //Overwritten output file. } printf("Finding first %d primes now.\n",n); //attempt to malloc memory for the array of size n. int *array = malloc(n * sizeof (int)); if (array == NULL) { printf("EVERYTHING IS ON FIRE."); //Failure! Perhaps n was too big. } else { //Calling workhorse of the function loopthrough(n,array); //Read out of array that has been modified for(i=0;i