Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 检查daytimetcpcli.c有一大堆的错误??
【标  题】:检查daytimetcpcli.c有一大堆的错误??
【关键字】:daytimetcpcli.c
【来  源】:http://blog.chinaunix.net/article.php?articleId=45947&blogId=761

检查daytimetcpcli.c有一大堆的错误??

Your Ad Here

 这是源程序:

#include "unp.h"
int
main(int argc,char **argv)
{
    int                     sockfd,n;
    char                    recvline[MAXLINE+1];
    struct sockaddr_in      servaddr;
    if(argc != 2) {
          printf("Usage : %s <IPaddress>\n",argv[0]);
          return(1);
    }
    if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) {
          printf("create socket error\n");
          return(1);
    }
    bzero(&servaddr,sizeof(servaddr));
    servaddr.sin_family=AF_INET;
    servaddr.sin_port=htons(13);
    if(inet_pton(AF_INET,argv[1],&servaddr.sin_addr) <= 0) {
          printf("inet_pton error\n");
          retrun(1);
    }
    if(connect(sockfd,(struct sockaddr *)&servaddr,sieof(servaddr))<0) {
          printf("connect error\n");
          return(1);
    }
    while((n=read(sockfd,recvline,MAXLINE))>0) {
          recvline[n]=0;    /* null terminate */
          if(fputs(recvline,stdout) == EOF ) {
                 printf("fputs error\n");
                 return(1);
          }
    }
    if(n<0) {
          printf("read error\n");
          return(1);
    }
    return(0);
}

 
un.h我是照着书抄的,估计没问题。以下是错误。@@@@@@

In file included from daytimetcpcli.c:1:
/usr/include/unp.h:10: syntax error before `/'
In file included from /usr/include/sys/inttypes.h:9,
                 from /usr/include/sys/types.h:48,
                 from /usr/include/unp.h:15,
                 from daytimetcpcli.c:1:
/usr/include/machine/ansi.h:146: syntax error before `__int64_t'
In file included from /usr/include/sys/types.h:48,
                 from /usr/include/unp.h:15,
                 from daytimetcpcli.c:1:
/usr/include/sys/inttypes.h:14: syntax error before `int64_t'
/usr/include/sys/inttypes.h:14: warning: data definition has no type or storage class
In file included from /usr/include/sys/types.h:49,
                 from /usr/include/unp.h:15,
                 from daytimetcpcli.c:1:
/usr/include/machine/types.h:51: syntax error before `vm_ooffset_t'
/usr/include/machine/types.h:51: warning: data definition has no type or storage class
In file included from /usr/include/unp.h:15,
                 from daytimetcpcli.c:1:
/usr/include/sys/types.h:66: syntax error before `quad_t'
/usr/include/sys/types.h:66: warning: data definition has no type or storage class
/usr/include/sys/types.h:67: syntax error before `*'
/usr/include/sys/types.h:67: warning: data definition has no type or storage class
/usr/include/sys/types.h:82: syntax error before `off_t'
/usr/include/sys/types.h:82: warning: data definition has no type or storage class
/usr/include/sys/types.h:84: syntax error before `rlim_t'
/usr/include/sys/types.h:84: warning: data definition has no type or storage class
In file included from /usr/include/unp.h:15,
                 from daytimetcpcli.c:1:
/usr/include/sys/types.h:198: syntax error before `off_t'
/usr/include/sys/types.h:202: syntax error before `lseek'
/usr/include/sys/types.h:202: syntax error before `off_t'
/usr/include/sys/types.h:202: warning: data definition has no type or storage class
/usr/include/sys/types.h:206: syntax error before `off_t'
/usr/include/sys/types.h:210: syntax error before `off_t'
In file included from /usr/include/unp.h:16,
                 from daytimetcpcli.c:1:
/usr/include/sys/socket.h:191: syntax error before `int64_t'
/usr/include/sys/socket.h:451: syntax error before `off_t'
In file included from /usr/include/unp.h:17,
                 from daytimetcpcli.c:1:
/usr/include/sys/time.h:147: syntax error before `int64_t'
In file included from /usr/include/unp.h:22,
                 from daytimetcpcli.c:1:
/usr/include/fcntl.h:181: syntax error before `off_t'
In file included from /usr/include/unp.h:25,
                 from daytimetcpcli.c:1:
/usr/include/stdio.h:55: syntax error before `fpos_t'
/usr/include/stdio.h:55: warning: data definition has no type or storage class
/usr/include/stdio.h:110: syntax error before `fpos_t'
/usr/include/stdio.h:127: syntax error before `fpos_t'
/usr/include/stdio.h:207: syntax error before `fpos_t'
/usr/include/stdio.h:217: syntax error before `*'
/usr/include/stdio.h:306: syntax error before `__int64_t'
/usr/include/stdio.h:307: syntax error before `ftello'
/usr/include/stdio.h:307: warning: data definition has no type or storage class
/usr/include/stdio.h:339: syntax error before `fpos_t'
/usr/include/stdio.h:339: syntax error before `fpos_t'
/usr/include/stdio.h:339: `funopen' declared as function returning a function
In file included from /usr/include/unp.h:26,
                 from daytimetcpcli.c:1:
/usr/include/stdlib.h:186: syntax error before `strtoq'
/usr/include/stdlib.h:186: warning: data definition has no type or storage class
In file included from /usr/include/unp.h:28,
                 from daytimetcpcli.c:1:
/usr/include/sys/stat.h:99: syntax error before `off_t'
/usr/include/sys/stat.h:105: syntax error before `int64_t'
/usr/include/sys/stat.h:129: syntax error before `off_t'
/usr/include/sys/stat.h:134: syntax error before `int64_t'
In file included from /usr/include/unp.h:30,
                 from daytimetcpcli.c:1:
/usr/include/unistd.h:135: syntax error before `off_t'
/usr/include/unistd.h:143: syntax error before `off_t'
/usr/include/unistd.h:145: syntax error before `off_t'
/usr/include/unistd.h:186: syntax error before `__syscall'
/usr/include/unistd.h:186: syntax error before `...'
/usr/include/unistd.h:186: warning: data definition has no type or storage class
In file included from daytimetcpcli.c:1:
/usr/include/unp.h:376: syntax error before `

 还是好好检查一下unp.h有什么打字错误。

 是你自己的问题,试着不用老大给的函数,用自己的写个呢

unp的问题


你是用的W.Richard.Stevens的unix programming 吧,他的unp头文件里面的函数分别实现在一些文件里面。
你用unp的话,要把那几个文件夹也放到你的user path里面去就好了。
 谢谢大家,原来是注释那里弄重复了/* /* some */*/

请问怎么得到config.h文件。我照着书去下载,不行哦。
recvline[n]=0 /* null terminate */ ______??:【上一篇】
请教一个共享内存问题:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 宽频路由器 IP515H
  • 申请免费的域名A纪录
  • UnixWare7.1.x操作系统下的硬盘管理
  • Ubuntu 6.06下安装svn1.4.2
  • 我又做了一件不可思议的事。。。
  • 使用 EmptyClass 避免条件判断
  • FreeBSD内核网络处理流程分析- -
  • Windows下采用mod_gzip模块加速Apache
  • 贝塔斯曼的IT系统
  • 关于web开发中如何彻底分离美工和后台程序工作的随想
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.