why ntohs(1byte_variable) works fine?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


why ntohs(1byte_variable) works fine?


uint8_t var = 9;
var = ntohs(var);



the same piece of code yields var value as 0 aswell 9.



As of my guess, as we can't apply ntohs on 1 byte filed!! can we? is there any case?.
how could final value of var after ntohs yields 9.


my linux machine is Little Endian ,x86 architecture, Intel



Thanks for your answer in advance.





I don't understand the difference between "in my project" and "i tried".
– Eugene Sh.
7 mins ago







the same code var value results once 0 aswell 9 also.
– aaripaka prashad
5 mins ago







On same machine?
– Eugene Sh.
5 mins ago





If printed properly the output should not be 0. Please update your question with a Minimal, Complete, and Verifiable example that others can compile and run that demonstrates the problem.
– dbush
2 mins ago





@dbush If network is BE and the host is LE - it should be 0 I think....
– Eugene Sh.
1 min ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived