warning: incompatible implicit declaration of built-in function ‘strlen’

warning: incompatible implicit declaration of built-in function ‘printf’  出现这样的警告一般是缺少头文件或者头文件不正确。

我的程序用到了函数strlen,以前在redhat9.0下编译可以通过,为什么在fedora8下面却出现错误?
源代码如下:

C/C++ code
    
    
    
    
#include < stdio.h > #include < sys / socket.h > #include < netinet / in .h >
    
    
    
    
#include <string.h> int main() { int s; char dgram[ 512 ]; char dd[ 512 ] = " hello client! " ; struct sockaddr_in adr_ser; struct sockaddr_in adr_cli; adr_ser.sin_family = AF_INET; adr_ser.sin_port = htons( 6666 ); adr_ser.sin_addr.s_addr = inet_addr( " 192.168.1.137 " ); s = socket(AF_INET,SOCK_DGRAM, 0 ); bind(s,( struct sockaddr * ) & adr_ser, sizeof (adr_ser)); int len = sizeof (adr_cli); recvfrom(s,dgram, sizeof (dgram), 0 ,( struct sockaddr * ) & adr_cli, & len); printf( " From client:%s\n " ,dgram); sendto(s, " Hello " ,strlen( " Hello " ) + 1 , 0 ,( struct sockaddr * ) & adr_cli,len); close(s); return 0 ; }


你可能感兴趣的:(warning: incompatible implicit declaration of built-in function ‘strlen’)