问题描述
对于十六进制转换,执行此操作更有效:
Printit是char,其低位表示要打印的半字节
cout<< " 0123456789ABCDEF" [Printit];
或:
const char hexdigits [17] =" 0123456789ABCDEF" ;
cout<< hexdigits [Printit];
或者不重要吗?
谢谢
Joe
for a hex conversion, Is it more efficient to do this :
Printit is the char whose low order bits represent the nibble to print
cout << "0123456789ABCDEF" [ Printit ] ;
or :
const char hexdigits [17] = "0123456789ABCDEF" ;
cout << hexdigits [ Printit ] ;
Or doesn''t it matter ?
Thanks
Joe
推荐答案
还有第三种方法:
const char * hexdigits =" 0123456789ABCDEF" ;;
cout<< hexdigits [Printit];
这并不重要。使用对你来说更方便的那个。
-
Ioannis
*编程页面:
*备选网址1:
*备选网址2:
There is and a third method:
const char *hexdigits="0123456789ABCDEF";
cout << hexdigits [Printit];
It doesn''t really matter. Use the one that is more convenient to you.
--
Ioannis
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
john
john
这些完全一样。
但是,您可以通过测试每一个来找到自己。
These are exactly the same.
However, you could find out for yourself by testing each one.
这篇关于效率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!