How much stack space have you got?
Code:
unsigned int meanarray[262144];
... could account for the problem; the stack does not usually have unlimited storage and you could be better off creating meanarray on the heap instead (with malloc, not forgetting to free it when you've done).

int is 4 bytes so this allocates 1MB of stack space.