char c=255;
int i=c;
what will be the value of i?
Unfortunately ,the answer is undefined.
It is implemention-defined whether a plain char is considerer signed or unsignded.
On a SGI Challenge machine,a char is unsigned,so the answer is 255. On a Sun SPARC or an IBM PC,where a char is signed,the answer is -1.
some standard library functions ,such as strcmp(), take plain chars only.
(C3.4 Signed and Unsigned Characters)
2007年9月18日星期二
promotions
Before an arithmetic operation is performed,integral promotion is used to create ints out of shorter integer types.(C.6.1 Promotions)
The Boolean,character,and integer types are collectively called integral types. The integral and floating-point types are collectively called arithmetic types .(4.1.1 Fundamental Types)
unsigned long val = 0;
char a = 0x48;
char b = 0x52;
val = b << 8 | a;
A 20992 B 21064 C 72 D 0
what is the answer?
The Boolean,character,and integer types are collectively called integral types. The integral and floating-point types are collectively called arithmetic types .(4.1.1 Fundamental Types)
unsigned long val = 0;
char a = 0x48;
char b = 0x52;
val = b << 8 | a;
A 20992 B 21064 C 72 D 0
what is the answer?
2007年9月11日星期二
10 Linux commands you've never used
10 Linux commands you've never used
介绍了10个linux下面的命令,但并非是never used
1.pgrep look up or signal processes based on name and other attributes
2.pstree display a tree of processes
3.bc An arbitrary precision calculator language
4.split split a file into pieces
5.nl number lines of files
6.mkfifo make FIFOs (named pipes)
7.ldd print shared library dependencies
8.col filter reverse line feeds from input
9.xmlwf Determines if an XML document is well-formed
10.lsof list open files
介绍了10个linux下面的命令,但并非是never used
1.pgrep look up or signal processes based on name and other attributes
2.pstree display a tree of processes
3.bc An arbitrary precision calculator language
4.split split a file into pieces
5.nl number lines of files
6.mkfifo make FIFOs (named pipes)
7.ldd print shared library dependencies
8.col filter reverse line feeds from input
9.xmlwf Determines if an XML document is well-formed
10.lsof list open files
订阅:
博文 (Atom)