Hello. I am trying to implement a recursive merge sort, and I've just barely begun. I am getting some warnings:
merge_sort.c:15: warning: ISO C90 forbids variable-size array 'left'
merge_sort.c:15: warning: ISO C90 forbids mixed declarations and code
Code:
#include <stdio.h>
#include <string.h>
static void
merge_sort(int *a, int n)
{
int mid;
int *y;
if (n > 1)
mid = n / 2;
y = a + mid;
int left[mid];
memcpy(left, a, mid);
}
int
main(int argc, char *argv[])
{
int uo[] = {2, 65, 23, 65, 734, 23, 45, 23, 67};
int n = sizeof uo / sizeof uo[0];
merge_sort(uo, n);
return 0;
}
I am using gcc 4.2.1 and I am compiling with -Wall and -pedantic.
Any ideas?