strcpy and inet_ntoa

This is a discussion on strcpy and inet_ntoa within the C Programming forums, part of the General Programming Boards category; Hoping for some guidance. I am trying to create a log record to save into a file for an assignment. ...

  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, 08: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, 08:34 AM
  5. inet_ntoa() or not?
    By PhilB in forum C Programming
    Replies: 1
    Last Post: 05-01-2002, 05:02 PM

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