Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4017974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:55:34+00:00 2026-05-20T09:55:34+00:00

char * src_addr; char * dst_addr; src_addr = inet_ntoa(ip->ip_src); printf(src: %s\n, src_addr); dst_addr =

  • 0
char * src_addr;
char * dst_addr;

src_addr = inet_ntoa(ip->ip_src);
printf("src: %s\n", src_addr);

dst_addr = inet_ntoa(ip->ip_dst);
printf("dst: %s\n", dst_addr);

printf("src: %s\n", src_addr);

This will output the dst_addr in the third printf statement. Am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:55:35+00:00Added an answer on May 20, 2026 at 9:55 am

    From the documentation: inet_ntoa() returns the dots-and-numbers string in a static buffer that is overwritten with each call to the function.

    So, in your case the second call to inet_ntoa gives you a new string but in the same buffer, so dst_addr points to the same as src_addr, which now both point to the new destination string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code: char *(*strcpy_ptr)(char *dst, const char *src); Pointer to strcpy-like function
printf( Src Address\n); for(i = 0;i < 4;i++) printf( %d ,((ip->ip_src.s_addr)&(0x0FF<<(i*8)))>>(i*8)); this displays o/p
char label[8] = abcdefgh; char arr[7] = abcdefg; printf(%s\n,label); printf(%s,arr); ====output========== abcdefgh abcdefgÅ Why
For example, I want such a function: char *dst = (char*)malloc(512); char *src =
I'm using the below code: char dest[5]; char src[5] = test; printf(String: %s\n, do_something(dest,
If I use Marshal::StringToHGlobalAnsi as following: char *src = (char *)Marshal::StringToHGlobalAnsi(this->Textbox1->Text).ToPointer(); Do I need
int length = strlen(src); char *structSpace = malloc(sizeof(String) + length + 1); String *string
char *strtok(char *s1, const char *s2) repeated calls to this function break string s1
char c='c'; int i=10; double d =50; long l=30; String s=Goodbye; Are these statement
{ char *a, *b; printf(%lx\n,(b-a)); } Usually works, in fact, I can't imagine it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.