Thread: don't understand error message

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    don't understand error message

    Not sure why I am getting this error message from this code:


    error:

    test_client.c: In function âmainâ:
    test_client.c:22: warning: incompatible implicit declaration of built-in function âprintfâ
    test_client.c:23: warning: incompatible implicit declaration of built-in function âexitâ



    code:


    Code:
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    
    #define MYPORT 22
    
    int main(void)
    {
        int sockfd;
        struct sockaddr_in my_addr;
    
        sockfd = socket(PF_INET, SOCK_STREAM, 0);
     
    
      if ((sockfd=socket(PF_INET, SOCK_STREAM, 0))==-1){  /* calls socket() */
        printf("socket() error\n");
        exit(-1);
      }
    }

    Can anyone please help me see the light?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Because you forgot to #include <stdio.h> and #include <stdlib.h>.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    2
    DUH!!!

    THANKS!!!

    man I feel dumb right now!

Popular pages Recent additions subscribe to a feed