JCM JCM - 1 month ago 57
C Question

:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token

I'm new to stackoverflow
I'm getting this error

gcc -Wall -o "merge" "merge.c" (in directory: /home/jenson/Documents)
Compilation failed.
merge.c: In function ‘part’:
merge.c:7:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
merge.c:18:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
merge.c:37:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
merge.c:3:6: error: old-style parameter declarations in prototyped function definition
void part(int a[], int n)
^
merge.c:54:1: error: expected ‘{’ at end of input
}
^


the code is:

#include<stdio.h>
#include<stdlib.h>
void part(int a[], int n)
void merge(int a[],int n);
void sort(int[],int[],int n);
void main()
{
int arr[10],i,n;
printf("enter the 10 numbers :\n");
for(i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
n=10;
part(arr,n);
}
void sort(int a[],int b[],int n)
{
int i=0,j=0,t=0,c[10];
while(i<n&&j<n)
{
if(a[i]>b[j])
{
c[t]=b[j];
j++;
t++
}
else
{
c[t]=a[i];
i++;
t++;
}
}
}
void part(int f[],int n)
{
int f[10],g[10];
if(n>=1)
{
int i;
for(i=0;i<floor(n/2);i++)
{
f[i]=d[i];
}
part(f,floor(n/2));
for(i=floor(n/2);i<n;i++)
{
g[i]=d[i];
}
part(f,feil(n/2));
}
sort(f,g,n);
}

Answer

semi-colon missing in the prototype declaration

void part(int a[], int n)
                         ^

Another one missing in sort() function, inside if

t++
   ^