青衿 发表于 2015-12-7 22:16:08

求帮忙,按着教程写,可怎么编译不了

本帖最后由 青衿 于 2015-12-7 22:19 编辑

C:\Users\lin\Desktop\未命名14.c        In function 'max':
6        2        C:\Users\lin\Desktop\未命名14.c        expected declaration specifiers before 'printf'
7        2        C:\Users\lin\Desktop\未命名14.c        expected declaration specifiers before 'scanf'
8        2        C:\Users\lin\Desktop\未命名14.c        expected declaration specifiers before 'z'
9        2        C:\Users\lin\Desktop\未命名14.c        expected declaration specifiers before 'printf'
11        1        C:\Users\lin\Desktop\未命名14.c        expected declaration specifiers before '}' token
14        1        C:\Users\lin\Desktop\未命名14.c        expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
16        1        C:\Users\lin\Desktop\未命名14.c        expected '{' at end of input
C:\Users\lin\Desktop\未命名14.c        In function 'main':
16        1        C:\Users\lin\Desktop\未命名14.c        expected declaration or statement at end of input
31                C:\Users\lin\Desktop\Makefile.win        recipe for target '未命名14.o' failed


int max(int a,int b);
main()            
{
        int x,y,z;         
        int max(int a,int b)   
        printf("input two numbers:\n");
        scanf("%d%d",&x,&y);
        z=max(x,y);         
        printf("maxmum=%d",z);   

}

int max(int a,int b)      
{
        if(a>b)return a;else return b;
}

斯塔德 发表于 2015-12-7 22:47:23

int max(int a,int b)   这里少了个分号啊.

斯塔德 发表于 2015-12-7 22:50:26

#include <stdio.h>

int max(int a,int b);
int main(void)
{
      int x,y,z;
      printf("input two numbers:\n");
      scanf("%d%d",&x,&y);
      z=max(x,y);
      printf("maxmum=%d",z);

}

int max(int a,int b)
{
      if(a>b)return a;else return b;
}

青衿 发表于 2015-12-7 23:23:55

斯塔德 发表于 2015-12-7 22:50


我那是哪里错了呢,我是按照小甲鱼的那个C语言设计第一节里面照抄的

斯塔德 发表于 2015-12-7 23:28:18

青衿 发表于 2015-12-7 23:23
我那是哪里错了呢,我是按照小甲鱼的那个C语言设计第一节里面照抄的

expected declaration specifiers before 'printf' 错误.你就看这行代码和上边一行的有没有问题.你的代码里
int max(int a,int b)   
printf("input two numbers:\n");
很明显你少了个分号. 而且这句不需要写在这里啊.

青衿 发表于 2015-12-7 23:33:30

斯塔德 发表于 2015-12-7 22:47
int max(int a,int b)   这里少了个分号啊.

懂了。谢谢了,还少了个开头,没错吧

青衿 发表于 2015-12-7 23:56:53

斯塔德 发表于 2015-12-7 23:28
expected declaration specifiers before 'printf' 错误.你就看这行代码和上边一行的有没有问题.你的代码 ...

我是刚学的,跟小甲鱼的那个教程抄的,
页: [1]
查看完整版本: 求帮忙,按着教程写,可怎么编译不了