Function return a value

This is a discussion on Function return a value within the C Programming forums, part of the General Programming Boards category; Originally Posted by cpjust Yes, but on a Little Endian machine, both ntohl() and htonl() swap bytes around. On a ...

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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.

Page 2 of 2 FirstFirst 12
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, 03: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, 07: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, 02:27 PM

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