Connor666 发表于 2022-4-2 10:12:05

大神帮忙看一下 这是个啥问题

#include <stdio.h>

void main()
{
        int f(int a,int b);
        int i =2,p;
        p=f(i,++i);
        printf("%d\n",p);

}
int f(int a ,int b);
{
                int c;
                if(a>b)
                {
                        c=1;
                }
                else if (a==b);
                {
                        c=0;
                }
                else
                {
                        c =-1;
                }
                return c;
}
提示如下;
--------------------Configuration: int f - Win32 Debug--------------------
Compiling...
int f.c
E:\Connor\000pJ\C_TEST\define\int f\int f.c(12) : error C2449: found '{' at file scope (missing function header?)
E:\Connor\000pJ\C_TEST\define\int f\int f.c(27) : error C2059: syntax error : '}'
执行 cl.exe 时出错.

int f.obj - 1 error(s), 0 warning(s)

ba21 发表于 2022-4-2 10:14:06

int f(int a ,int b);

wp231957 发表于 2022-4-2 10:14:35

这个分号是神马鬼else if (a==b);

wp231957 发表于 2022-4-2 10:15:40

p=f(i,++i);这种代码!!!!

傻眼貓咪 发表于 2022-4-2 10:16:36

#include <stdio.h>

int main() // 不要写 void main() 这种东西
{
      int f(int a,int b);
      int i =2,p;
      p=f(i,++i);
      printf("%d\n",p);

}
int f(int a ,int b)// <------ 注意这里
{
               int c;
                if(a>b)
                {
                        c=1;
                }
                else if (a==b)// <------ 注意这里
                {
                        c=0;
                }
                else
                {
                        c =-1;
                }
                return c;
}

Connor666 发表于 2022-4-2 10:29:54

傻眼貓咪 发表于 2022-4-2 10:16


好的 感谢

Connor666 发表于 2022-4-2 10:30:26

Connor666 发表于 2022-4-2 10:29
好的 感谢

有这个软件的链接吗 我这个总是会崩掉
页: [1]
查看完整版本: 大神帮忙看一下 这是个啥问题