Thread: strcpy and inet_ntoa

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    10

    strcpy and inet_ntoa

    Hoping for some guidance. I am trying to create a log record to save into a file for an assignment.

    The first line of the code works with no problem. The second line of code is throwing an error:

    proj4.c:188: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast

    I'm not certain I understand why. Isn't inet_ntoa returning a char pointer? Why can't I copy that to the log? Log is declared as char log[1024]

    char *inet_ntoa(struct in_addr in); <---returns a char *?

    Code:
            printf("IP of requestor %s\n", inet_ntoa(remote.sin_addr));
            strcpy(log, inet_ntoa(remote.sin_addr));

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    10
    Nevermind - I was missing the include.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2010, 07:42 AM
  2. inet_ntoa to strings
    By TomChesley in forum Networking/Device Communication
    Replies: 7
    Last Post: 02-24-2009, 05:01 PM
  3. Replies: 1
    Last Post: 04-05-2003, 08:39 AM
  4. HELP!! strcpy
    By abbynormal87 in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2002, 07:34 AM
  5. inet_ntoa() or not?
    By PhilB in forum C Programming
    Replies: 1
    Last Post: 05-01-2002, 04:02 PM