#include "sorting.h" #include #include long *Load_File(char *Filename, int *Size) { int i = 0; // Array element counter long l = 0; long *Array = NULL; // Pointer to the array FILE *fp = NULL; // Pointer to the input file // Attempt to open input file if((fp = fopen(Filename,"r")) == NULL) { printf("Error opening input file %s!\n", *Filename); return(NULL); } // Read number of array elements in input file fscanf(fp,"%d\n", Size); // Attempt to allocate the appropriate sized array if((Array = (long *)malloc(*Size * sizeof(long))) == NULL) { printf("Error allocating memory for array!\n"); return(NULL); } while(fscanf(fp,"%d\n", Array++) != EOF) { // Array[i] = l; printf("Loading Array[%d] = %d\n",i++,*(Array -1)); } fclose(fp); return(Array); } int main() { int ArraySize = 0; int i; long *Array = NULL; char *Filename = "1000.txt"; printf("Initialized Variables\n"); Array = Load_File(Filename, &ArraySize); printf("Loaded Array with %s\n", Filename); for(i = 0; i < ArraySize; i++) { printf("%d\n", *Array++); } return (0); }