I was hoping to get a bit of help, I am implementing an inversion counter algorithm to take in 50,000 intergers and display the inversions and time it took to run the algorithm, I am having a hard time allocating and saving the integers from the file into an array. My code complies and runs but nothing happens here is what I have:
int main(int argc, char** argv)
{
 int n, i;
 int inversions=0;
 int *A;
 FILE *file;
 char filename[100];
 clock_t start, end;
 double totalTime;
 printf("Enter filename: ");
 scanf("%s", filename);
 file = fopen(filename, "r");
 if(file == NULL)
 {
   printf("Error opening file!\n");
   return 0;
 }
 fscanf(file, "%d", &n);
 A = (int*) malloc(n * sizeof(int));
 for(i = 0; i < n; i++) {
 fscanf(file, "%d", &A[i]);
}
 start = clock();
 inversions = countInversionsBruteForce(A, n);
 end = clock();
 totalTime = (double) (end - start) / CLOCKS_PER_SEC;
 printf("Brute Force Algorithm\n");
 printf("Number of inversions: %d\n", inversions);
 printf("Execution time: %f\n", totalTime);
I think I have noth allocated array size and saved it properly
 
    