Thread: Function return a value

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by cpjust View Post
    Yes, but on a Little Endian machine, both ntohl() and htonl() swap bytes around. On a Big Endian machine, both ntohl() and htonl() do nothing.
    Right -- ntohl and htonl both do the same thing as each other (assuming consistent bytes) -- but they don't necessarily do the same thing as OP's code. Looking back, your point was probably that ntohl and htonl do the same thing regardless, so there's no need to "choose". I'm pretty sure my point was that yes, sometimes you have to type "ntohl" and sometimes you have to type "htonl", but (1) why reinvent the wheel and (2) it's nice if you can tell just by looking why you're flipping something around.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Yeah, having two names is probably just for convenience. It makes it easier to read code. It seems like they could have just had one function, but maybe coming up with a good name would be a problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM