don't understand error message

This is a discussion on don't understand error message within the C Programming forums, part of the General Programming Boards category; 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 ...

  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,185
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21