Hi fellow programmers, I have some code that appears syntactically correct to me, however when i compile in on the Unversitites UNIX server, find that i get a couple of errors that really do not make sense to me. Hence, i thought i should post it on a forum and get somebodies expert opinion. Here is the code snipped:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> void insert_sort(int a[],int n) int main() { int i; int array[INDEX] = {6,4,2,5,1,2,8,3,7,9}; printf("Before the sort:\n"); for(int i=0;i<INDEX;i++) printf("%d", array[i]); printf("\n"); insert_sort(array,INDEX); printf("After the sort:\n"); for(int i=0;i<INDEX;i++) printf("%d \n", array[i]); return 0; } void insert_sort(int a[],int n) { int j, p; int tmp; for(p = 1; p < n; p++) { tmp = a[p]; for(j = p; j > 0 && a[j-1] > tmp; j--) a[j] = a[j-1]; a[j] = tmp; } } -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Here is also a copy of the cryptic code message: [EMAIL PROTECTED] Wk2]$ clearcc -ansi -Wall -o -Pendatic sorting_array.c sorting_array.c: In function `insert_sort': sorting_array.c:9: warning: 'main' is usually a function sorting_array.c:9: error: syntax error before '{' token sorting_array.c:11: error: `INDEX' undeclared (first use in this function) sorting_array.c:11: error: (Each undeclared identifier is reported only once sorting_array.c:11: error: for each function it appears in.) sorting_array.c:11: confused by earlier errors, bailing out -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Thank you for anybody who is a help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---