| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2674 人关注过本帖
标题:g c c编译器报错,类型冲突!!!
只看楼主 加入收藏
a1771600116
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-7-11
收藏
 问题点数:0 回复次数:1 
g c c编译器报错,类型冲突!!!
#include<stdio.h>
#define MAXLINE 1000    /* maximum input line length */
int getline(char line[], int maxline);
void copy(char to[], char from[]);
/* print the longest input line */
main()
{
    int len;        /*  current line length */
    int max;        /* maximum length seen so far */
    char line[MAXLINE]; /* current input line */
    char longest[MAXLINE]; /* longest line saved here */
    max = 0;
    while ((len = getline(line, MAXLINE)) > 0)
        if (len > max)
        {
            max = len;
            copy(longest, line);
        }
    if (max > 0)    /* there was a line */
        printf("%s",longest);
    return 0;
}
/* getline: read a line into s , return length */
int getline(char s[],int lim)
{
    int c,i;
    for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n';++i)
        s[i] = c;
    if (c == '\n')
    {
        s[i]=c;
        ++i;
    }
    s[i] = '\0';
    return i;
}
/* copy: copy 'from' into 'to';assume to is big enough */
void copy(char to[], char from[])
{
    int i;
    i = 0;
    while((to[i] = from[i]) != '\0')
        ++i;
}
这是书本上例子,可是我计算机上总算报错,求解
错误代码:
char_length.c:4:5: 错误: 与‘getline’类型冲突
In file included from char_length.c:1:0:
/usr/include/stdio.h:678:20: 附注: ‘getline’的上一个声明在此
char_length.c:28:5: 错误: 与‘getline’类型冲突
In file included from char_length.c:1:0:
/usr/include/stdio.h:678:20: 附注: ‘getline’的上一个声明在此
Shell 已返回1
搜索更多相关主题的帖子: current include 编译器 
2013-07-11 10:17
a1771600116
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-7-11
收藏
得分:0 
呵呵解决了。名字问题,改个名字就行了。
2013-07-11 10:39
快速回复:g c c编译器报错,类型冲突!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017201 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved