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

  • SEARCH
  • Home
  • 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 8870497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:44:52+00:00 2026-06-14T17:44:52+00:00

I was trying to figure out a piece of code which constructs a hostent

  • 0

I was trying to figure out a piece of code which constructs a hostent object, more specifically, the part of it’s work that populates the h_addr_list array.

I was confused by the fact that the values that were assigned into the array were cast to char*, seeing as this array has nothing to do with strings as far as I read.

I noticed that the h_addr_list array is actually typed as char**.

The only place I saw that takes note of this fact is section 9.7 in beej’s Guide to Network Programming, but even there there’s no explanation on why is it typed so.

Is there a reason that h_addr_list is typed as char** and not void*/void** (or anything else that might be a bit more informative)?

  • 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-06-14T17:44:54+00:00Added an answer on June 14, 2026 at 5:44 pm

    char * needn’t necessarily refer to a C string, but also to a chunk of memory of known length that needs to be addressed by byte, presumably because it arrives from the network.

    Before types like int8_t and uint8_t were added to C99, char * was the only practical way to refer to a contiguous byte array. In fact, struct hostent predates C89 which formalized the void type. If written today, the field would be declared as void ** or possibly uint8_t **.

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

Sidebar

Related Questions

I am trying to figure out how to simplify this piece of code. The
I'm stuck and can't figure this out. I have this piece of code which
I'm trying to figure out what this piece of code does: std::vector<std::vector<bool> > visited(rows,
i was trying to figure out what is wrong with this piece of code,
I'm trying to figure out what's going on on this piece of code, trying
Trying to figure out which to use.
I have been trying to figure out the best practices to write test-friendly code,
Now that I've upgraded to Rails 3, I'm trying to figure out the proper
I'm trying to figure out serialization of .net arrays to XML. Here's a piece
Trying to figure out how I can do this properly. The print_r looks like

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.