C/C++Êý¾ÝÀàÐÍ(ÍøÉÏ×ÊÁÏ×ܽá)
1. cÓïÑÔÖеÄÕûÊýÀàÐÍÓÐchar, short, int, longµÈ¼¸ÖÖ, ÏÂÃæÊÇCÓïÑÔ¶ÔÿÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ¹æ¶¨:
(a). shortºÍlongÀàÐ͵ij¤¶È²»Ïàͬ
(b). intÀàÐÍͨ³£Í¬¾ßÌå»úÆ÷µÄÎïÀí×Ö³¤Ïàͬ
(c). shortͨ³£ÊÇ16bits, intͨ³£ÊÇ16bits or 32bitsÿÖÖ±àÒëÆ÷¿ÉÒÔ¸ù¾ÝÓ²¼þµÄ²»Í¬×ÔÓÉÈ·¶¨, µ«ÊÇshortºÍint±ØÐë×îÉÙÊÇ16bits, ¶ølongÀàÐͱØÐë×îÉÙÊÇ32bits, ²¢ÇÒshort±ØÐë±ÈintºÍlongÀàÐÍÒª¶Ì¡£
2. sizeof() ÔËËã·û·µ»ØµÄÊÇÒ»ÖÖÊý¾ÝÀàÐÍÖÐËù°üº¬µÄ×Ö½ÚÊý(bytes), AnsiC¹æ¶¨sizeof(char)±ØÐë·µ»Ø1£¬µ±sizeof×÷ÓÃÓÚÊý×éʱ, ·µ»ØµÄÊÇÊý×éÖÐËùÓгÉÔ±ËùÕ¼µÄ×Ö½ÚÊý(×¢Òâ²¢²»ÊÇÊý×éÖгÉÔ±µÄ¸öÊý), µ±sizeof()×÷ÓÃÓڽṹÌåºÍ¹«ÓÃÌåʱ,·µ»ØµÄ²»½ö½öÊÇÊý¾Ý³ÉÔ±×ܵÄ×Ö½ÚÊý, »¹°üÀ¨±àÒëÆ÷ΪÁËʵÏÖ×Ö½Ú¶ÔÆä¶øÌî³äµÄÄÇЩ×Ö½Ú¡£
---------------------------------------------------------------------------------------------------------------------------------------------
C++Êý¾ÝÀàÐͳ¤¶ÈÎÊÌâ:
Ò»¡¢×Ö½ÚºÍ×Ö³¤
×Ö½Ú£¬°Ëλ¾ÍÊÇÒ»¸ö×Ö½Ú£¬Êǹ̶¨¸ÅÄî¡£×Ö³¤ÊÇÖ¸¼ÆËã»úÒ»´ÎÄÜ´¦ÀíµÄ¶þ½øÖÆÊý¾ÝµÄ³¤¶È£¬ÊÇÒ»¸ö·Ç¹Ì¶¨µÄ¸ÅÄî¡£ÀýÈ磬8λ¼ÆËã»úµÄ×Ö³¤Îª8£¬¼´Ò»¸ö×Ö½Ú£¬ 32λ¼ÆËã»úµÄ×Ö³¤Î»32£¬¼´4¸ö×Ö½Ú£¬Í¬Àí£¬64λ¼ÆËã»úµÄ×Ö³¤Îª64£¬¼´8×Ö½Ú¡£
¶þ¡¢C++ÖеÄÊý¾ÝÀàÐÍ
1¡¢×Ö·ûÐÍÊý¾Ýchar£¬¸ÃÀàÐÍʼÖÕÊÇÒ»¸ö×Ö½Ú³¤£¬¼´8λ¡£
2¡¢ÕûÐÎint¡¢¶ÌÕûÐÍshortºÍ³¤ÕûÐÎlong¡£Í¨³£intΪһ¸ö×Ö³¤£¬shortΪ°ë¸ö×Ö³¤£¬longΪһ¸ö»ò2¸ö×Ö³¤£¨ÔÚ32λ»úÆ÷ÖÐΪһ¸ö×Ö³¤£©¡£
3¡¢¸¡µãÐÍfloat¡¢Ë«¾«¶Èdouble¡¢ºÍ³¤Ë«¾«¶Èlong double£¬·Ö±ð±íʾµ¥¾«¶È¸¡µãÊý Ë«¾«¶È¸¡µãÊýºÍÀ©Õ¹¾«¶ÈµÄ¸¡µãÊýÖµ¡£µäÐÍÇé¿öÏ£¬float Ϊһ¸ö×Ö£¬doubleÊÇÁ½¸ö×Ö£¬long doubleΪÁ½¸ö»òÈý¸ö»òËĸö×Ö¡£
char£¬short£¬intºÍlongÀàÐÍ·Ö±ðÓж೤?
Æ䳤¶È·Ö±ðΪһ×Ö½Ú£¬ÖÁÉÙÁ½×Ö½Ú£¬ÖÁÉÙÁ½×Ö½ÚºÍÖÁÉÙ4×Ö½Ú¡£³ý´ËÖ®Í⣬²»ÒªÔÙÒÀÀµÈκÎÔ¼¶¨¡£
charÀàÐ͵ij¤¶È±»¶¨ÒåΪһ¸ö8λ×Ö½Ú£¬ÕâºÜ¼òµ¥¡£
shortÀàÐ͵ij¤¶ÈÖÁÉÙΪÁ½×Ö½Ú¡£ÔÚÓÐЩ¼ÆËã»úÉÏ£¬¶ÔÓÚÓÐЩ±àÒë³ÌÐò£¬shortÀàÐ͵ij¤¶È¿ÉÄÜΪ4×Ö½Ú£¬»òÕ߸ü³¤¡£
intÀàÐÍÊÇÒ»¸öÕûÊýµÄ“×ÔÈ»”´óС£¬Æ䳤¶ÈÖÁÉÙΪÁ½×Ö½Ú£¬²¢ÇÒÖÁÉÙÒªºÍshortÀàÐÍÒ»Ñù³¤¡£ÔÚ16λ¼ÆËã»úÉÏ£¬intÀàÐ͵ij¤¶È¿ÉÄÜΪÁ½×Ö½Ú£»ÔÚ32λ¼ÆËã»úÉÏ£¬¿ÉÄÜΪ4×Ö½Ú£»µ±64λ¼ÆËã»úÁ÷ÐÐÆðÀ´ºó£¬intÀàÐ͵ij¤¶È¿ÉÄÜ»á´ïµ½8×Ö½Ú¡£ÕâÀï˵µÄ¶¼Ê
Ïà¹ØÎĵµ£º
·ÃÎÊNand FlashʱÐèÒªÏÈ·¢³öÃüÁȻºó·¢³öµØÖ·ÐòÁУ¬×îºó¶Á/дÊý¾Ý£»
ÐèҪʹÓø÷¸öÐźÅÀ´·Ö±æÃüÁî¡¢µØÖ·¡¢Êý¾Ý£»
S3C2410 µÄNand Flash¿ØÖÆÆ÷ ÌṩÁËÏà¹Ø¼Ä´æÆ÷À´¼ò»¯ÕâЩ²Ù×÷£º
& ......
ÓÃÁËÈýÖÖ·½·¨...
#if 0
void StringTokenize(const std::string& strSrc, const std::string& strDelimit, std::vector<std::string>& vecSub)
{
if (strSrc.empty() || strDelimit.empty())
{
throw "tokenize: empty string\n";
......
ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔÀ´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
memcached_st *memc;
uint32_t&nbs ......
/*±¾ÎÄÑ¡×Ô²©´´linuxʵÑéÖ¸µ¼Êé
*Áô×Å×Ô¼ºÑ§Ï°Ö®ÓÃ
*ÔÚÕâÀï±£´æ×Å£¬·ÖÏíÒ»ÏÂ*/
VI ¼ò½é
vi ÊÇ Linux/Unix ÊÀ½çÀKΪÆÕ±éµÄ¿ÉÊÓ»¯µÄÈ«ÆÁÄ»Îı¾±à¼Æ÷(visual edit),¼¸ºõ¿É
ÒÔ˵ÈκÎһ̨ Linux/Unix »úÆ÷¶¼»áÌṩÕâ¸öÈí¼þ¡£
vi ÓÐÈýÖÖ״̬,¼´±à¼·½Ê½¡¢²åÈ뷽ʽºÍÃüÁî·½Ê ......
Ò»£® ºÎν¿É±ä²ÎÊý
int printf( const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔÐÍ£¬ËüµÄ²ÎÊýÖоÍÓй̶¨²ÎÊýformatºÍ¿É±ä²ÎÊý£¨Óᱡ¡±±íʾ£©¡£
¶øÎÒÃÇÓÖ¿ÉÒÔÓø÷ÖÖ·½Ê½À´µ÷ÓÃprintf,Èç:
printf("%d",value);
printf("%s",str);
printf("the number is %d ,st ......