|
-
Sep 21st, 2001, 09:57 AM
#1
Thread Starter
Lively Member
Newbie Help
I am brand new at C and just messing aound can anyone tell me what is wrong with this code:
#include <stdio.h>
void sort_array(int a[])
int main()
{
int the_array[5]={9,5,0,2,1};
sort_array(the_array);
return 0;
}
void sort_array(int a[])
{
int i, j, temp;
for (i=0; i < 5; ++i)
{
for(j = 4; j > i; --j)
{
if (a[j-1] < a[j])
{
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
}
}
printf("%d",a[0]);
}
these are the errors when building:
C:\My Documents\Class\GradedAssign.c(5) : error C2085: 'main' : not in formal parameter list
C:\My Documents\Class\GradedAssign.c(5) : error C2143: syntax error : missing ';' before '{'
C:\My Documents\Class\GradedAssign.c(8) : warning C4098: 'sort_array' : 'void' function returning a value
C:\My Documents\Class\GradedAssign.c(12) : error C2084: function 'void __cdecl sort_array(int *)' already has a body
Thanks
Don't ever Ginop before you Ginip 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|