简体   繁体   English

:1:错误:在'{'标记之前应为'=',',',';','asm'或'__attribute__'

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

I'm new to stackoverflow I'm getting this error 我是Stackoverflow的新手,却收到此错误

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);
}

semi-colon missing in the prototype declaration 原型声明中缺少分号

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

Another one missing in sort() function, inside if ifsort()函数中缺少另一个

t++
   ^

Your code , after recompiling it many times , should be like this i think i did helped you . 您的代码经过多次重新编译后,应该像这样,我认为我确实对您有所帮助。

#include<stdio.h>
#include<stdlib.h>
#include <math.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 a[10],g[10],d[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,ceil(n/2));
    }
    sort(f,g,n);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:“ {”令牌|之前的预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token| 错误:在&#39;:&#39;标记前应有&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token 错误:在'{'令牌之前预期'=',',',';','asm'或'__attribute__' - error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token 错误:在 '.' 之前应有 '='、','、';'、'asm' 或 '__attribute__' 令牌 - error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 错误:在“*”标记之前应有“=”、“、”、“;”、“asm”或“__attribute__” - error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token 仍然是“错误:在&#39;*&#39;标记之前出现预期的&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39;” - Still the “error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token” 在&#39;&#39;之前预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39;。 代币 - expected '=', ',', ';', 'asm' or '__attribute__' before '.' token “在&#39;-&gt;&#39;标记之前的预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - "Expected '=', ',', ';', 'asm' or '__attribute__' before '->' token 在&#39;{&#39;令牌之前预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token 错误:预期在“ void”之前出现“ =”,“,”,“;”,“ asm”或“ __attribute__” - error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM