I am having troubles getting my program to work. It is supposed to take integers from a file and put them into an array. Then it is supposed to sort them by the bubble sort algorithm.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define N 10000
int main(int argc, char *argv[])
{
int i,j, k;
int *ptr;
int *temp;
FILE *fp;
fp=fopen(argv[i], "r");
if(fp==NULL)
{
fprintf(stdout, "could not open %s\n", argv[i]);
exit(EXIT_FAILURE);
}
fread(argv[i], sizeof(argv[i]), sizeof(argv[i]), fp);
while (fscanf(fp, "%d", ptr)!=EOF))
{
int m=0, *a[N];
ptr=a[m];
m++;
}
for(k=0; k<N-1; k++)
{
if(a[k]>a[k+1])
{
temp=a[k+1];
a[k+1]=a[k];
a[k]=temp;
}
}
printf("%d", a);
}
return 0;
}