Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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×Ö½Ú¡£ÕâÀï˵µÄ¶¼Ê


Ïà¹ØÎĵµ£º

CÓïÑÔ±àдlinuxϵÄÊØ»¤½ø³Ì

ÀûÓÃ
ÏÂÔصÄÕâ¶Î´úÂ룬³É¹¦ÊµÏÖÁËÊØ»¤½ø³Ì£¬Ô­À´ÊØ»¤½ø³ÌÊǺܼòµ¥µÄÊÂÇé¡£
¡¡¡¡ÔÚmainº¯ÊýÖÐÖ´ÐÐ
¡¡¡¡init_daemon();//³õʼ»¯ÎªDaemon
¡¡¡¡¾Í¿ÉÒ԰ѽø³Ì±ä³ÉÊØ»¤½ø³Ì
¡¡¡¡
#include
#include
#include
#include
#include
void
 init_daemon(void
)
{
int
 pid;
int
 i;
if
(pid=fork()) ......

memcachde Óë c/c++ Ó¦ÓÃ

ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔ­À´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
    memcached_st *memc;
    uint32_t&nbs ......

linuxÏÂcÓïÑÔ±à³Ì vi ¼ò½é

 /*±¾ÎÄÑ¡×Ô²©´´linuxʵÑéÖ¸µ¼Êé
*Áô×Å×Ô¼ºÑ§Ï°Ö®ÓÃ
*ÔÚÕâÀï±£´æ×Å£¬·ÖÏíÒ»ÏÂ*/
VI ¼ò½é
    vi ÊÇ Linux/Unix ÊÀ½çÀKΪÆÕ±éµÄ¿ÉÊÓ»¯µÄÈ«ÆÁÄ»Îı¾±à¼­Æ÷(visual edit),¼¸ºõ¿É
ÒÔ˵ÈκÎһ̨ Linux/Unix »úÆ÷¶¼»áÌṩÕâ¸öÈí¼þ¡£
    vi ÓÐÈýÖÖ״̬,¼´±à¼­·½Ê½¡¢²åÈ뷽ʽºÍÃüÁî·½Ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ