**ordenar leyendo con mergesort un archivo con una lista de N numeros . aqui dejo mi codigo pero me tira errores quien me ayuda
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void merge(int lo, int m, int hi)
{
int i,j,k;
for(i=lo ; i<hi; i++)
{
b[i]=a[i];
i=lo;
j=m+1;
k=lo;
while(i<=m && j<=hi)
{
if(b[i] && j<=hi)
{
a[k++]=b[i++];
}
else
{
a[k++]=b[j++];
}
while( i <=m )
{
a[k++] = b[i++];
}
}
}
}
void mergesort (int first, int last, int a)
{
if (last - first > 1)
{
int middle = first + (last - first);
mergesort(first, middle, a);
mergesort(middle, last, a);
merge(first, middle, last, a);
}
}
int main ()
{
float total,inicio, final;
inicio=clock();
FILE *ofp, *ifp;
ifp = fopen("aleatorio.txt","r"); //leo la cantidad N de datos a ordenar.
int N, aux, i;
fscanf(ifp,"%i", &N);
int d[N];
i=0;
for(i=0;i<N;i++)
{
fscanf(ifp,"%i", &d[i]);
}
ofp = fopen("merge_dec.txt","w");
int n;
n=N;
for(i=0;i<n;i++)
{
fprintf(ofp,"%i \n",mergesort(d[0], d[N]), N);
}
fclose(ofp);
fclose(ifp);
final=clock();
total=(final-inicio)/(double) CLOCKS_PER_SEC;
printf("%f\n",total);
return 0;
}
______________
ERRORES
merge_dec.c: In function ‘merge’:
merge_dec.c:10: error: ‘b’ undeclared (first use in this function)
merge_dec.c:10: error: (Each undeclared identifier is reported only once
merge_dec.c:10: error: for each function it appears in.)
merge_dec.c:10: error: ‘a’ undeclared (first use in this function)
merge_dec.c: In function ‘mergesort’:
merge_dec.c:41: error: too many arguments to function ‘merge’
merge_dec.c: In function ‘main’:
merge_dec.c:69: error: too few arguments to function ‘mergesort’
make: *** [merge_dec] Error 1
saludos