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

CÖеĿɱä²ÎÊýÑо¿

CÖеĿɱä²ÎÊýÑо¿
Ò»£® ºÎν¿É±ä²ÎÊý
int
printf( const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔ­ÐÍ£¬ËüµÄ²ÎÊýÖÐ
¾ÍÓй̶¨²ÎÊýformatºÍ¿É±ä²ÎÊý£¨ÓÔ…”±íʾ£©. ¶øÎÒÃÇÓÖ¿ÉÒÔÓø÷ÖÖ·½Ê½À´µ÷ÓÃprintf,Èç:
printf("%d",value);

printf("%s",str);
printf("the number is %d ,string is:%s",
value, str);
¶þ.ʵÏÖÔ­Àí
C
ÓïÑÔÓúêÀ´´¦ÀíÕâЩ¿É±ä²ÎÊý¡£ÕâЩºê¿´ÆðÀ´ºÜ¸´ÔÓ£¬ÆäʵԭÀíͦ¼òµ¥£¬¾ÍÊǸù¾Ý²ÎÊýÈëÕ»µÄÌصã´Ó×î¿¿½üµÚÒ»¸ö¿É±ä²ÎÊýµÄ¹Ì¶¨²ÎÊý¿ªÊ¼£¬ÒÀ´Î»ñȡÿ¸ö¿É±ä²ÎÊý
µÄµØÖ·¡£ÏÂÃæÎÒÃÇÀ´·ÖÎöÕâЩºê¡£ÔÚVCÖеÄstdarg.hÍ·ÎļþÖУ¬Õë¶Ô²»Í¬Æ½Ì¨Óв»Í¬µÄºê¶¨Ò壬ÎÒÃÇÑ¡È¡X86ƽ̨ϵĺ궨Ò壺
typedef
char *va_list;
/*°Ñva_list±»¶¨Òå³Échar*£¬ÕâÊÇÒòΪÔÚÎÒÃÇÄ¿Ç°ËùÓõÄPC»úÉÏ£¬×Ö·ûÖ¸ÕëÀàÐÍ¿ÉÒÔÓÃÀ´´æ´¢ÄÚ´æµ¥
ÔªµØÖ·¡£¶øÔÚÓеĻúÆ÷ÉÏva_listÊDZ»¶¨Òå³Évoid*µÄ*/
#define _INTSIZEOF(n) ( (sizeof(n) +
sizeof(int) - 1) & ~(sizeof(int) - 1) )
/*_INTSIZEOF(n)ºêÊÇΪÁË¿¼ÂÇÄÇЩÄÚ´æ
µØÖ·ÐèÒª¶ÔÆëµÄϵͳ£¬´ÓºêµÄÃû×ÖÀ´Ó¦¸ÃÊǸúsizeof(int)¶ÔÆë¡£Ò»°ãµÄsizeof(int)=4£¬Ò²¾ÍÊDzÎÊýÔÚÄÚ´æÖеĵØÖ·¶¼Îª4µÄ±¶Êý¡£±È
È磬Èç¹ûsizeof(n)ÔÚ1£­4Ö®¼ä£¬ÄÇô_INTSIZEOF(n)£½4£»Èç¹ûsizeof(n)ÔÚ5£­8Ö®¼ä£¬ÄÇô
_INTSIZEOF(n)=8¡£*/
#define va_start(ap,v)( ap = (va_list)&v +
_INTSIZEOF(v) )
/*va_startµÄ¶¨ÒåΪ &v+_INTSIZEOF(v)
,ÕâÀï&vÊÇ×îºóÒ»¸ö¹Ì¶¨²ÎÊýµÄÆðʼµØÖ·£¬ÔÙ¼ÓÉÏÆäʵ¼ÊÕ¼ÓôóСºó£¬¾ÍµÃµ½Á˵ÚÒ»¸ö¿É±ä²ÎÊýµÄÆðʼÄÚ´æµØÖ·¡£ËùÒÔÎÒÃÇÔËÐÐ
va_start(ap, v)ÒÔºó,apÖ¸ÏòµÚÒ»¸ö¿É±ä²ÎÊýÔÚµÄÄÚ´æµØÖ·*/
#define va_arg(ap,t) ( *(t
*)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
/*Õâ¸öºê×öÁËÁ½¸öÊÂÇ飬
¢ÙÓÃÓû§ÊäÈëµÄÀàÐÍ
Ãû¶Ô²ÎÊýµØÖ·½øÐÐÇ¿ÖÆÀàÐÍת»»£¬µÃµ½Óû§ËùÐèÒªµÄÖµ
¢Ú¼ÆËã³ö±¾²ÎÊýµÄʵ¼Ê´óС£¬½«Ö¸Õëµ÷µ½±¾²ÎÊýµÄ½á⣬Ҳ¾ÍÊÇÏÂÒ»¸ö²ÎÊýµÄÊ×µØÖ·£¬ÒÔ±ãºóÐø´¦
Àí¡£*/
¡¡¡¡#define va_end(ap) ( ap = (va_list)0 )
/*x86ƽ̨¶¨ÒåΪap=
(char*)0;ʹap²»ÔÙ
Ö¸Ïò¶ÑÕ»,¶øÊǸúNULLÒ»Ñù.ÓÐЩֱ½Ó¶¨ÒåΪ((void*)0),ÕâÑù±àÒëÆ÷²»»áΪva_end²úÉú´úÂë,ÀýÈçgccÔÚlinuxµÄx86ƽ̨¾ÍÊÇÕâ
Ñù¶¨ÒåµÄ. ÔÚÕâÀï´ó¼ÒҪעÒâÒ»¸öÎÊÌâ:ÓÉÓÚ²ÎÊýµÄµØÖ·ÓÃÓÚva_startºê,ËùÒÔ²ÎÊý²»ÄÜÉùÃ÷Ϊ¼Ä´æÆ÷±äÁ¿»ò×÷Ϊº¯


Ïà¹ØÎĵµ£º

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 ......

¸ßÖÊÁ¿C++/C±à³ÌÖ¸ÄÏ ÄÚ´æ¹ÜÀí

µÚ7Õ ÄÚ´æ¹ÜÀí
»¶Ó­½øÈëÄÚ´æÕâƬÀ×Çø¡£Î°´óµÄBill Gates Ôø¾­Ê§ÑÔ£º
640K ought to be enough for everybody
— Bill Gates 1981
³ÌÐòÔ±ÃǾ­³£±àдÄÚ´æ¹ÜÀí³ÌÐò£¬ÍùÍùÌáÐĵõµ¨¡£Èç¹û²»Ïë´¥À×£¬Î¨Ò»µÄ½â¾ö°ì·¨¾ÍÊÇ·¢ÏÖËùÓÐDZ·üµÄµØÀײ¢ÇÒÅųýËüÃÇ£¬¶ãÊǶ㲻Á˵ġ£±¾ÕµÄÄÚÈݱÈÒ»°ã½Ì¿ÆÊéµÄÒªÉîÈëµÃ¶à£¬¶ÁÕßÐèϸР......

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ÀàÐͱØÐë× ......

C/C++ÐÞ¸ÄÎı¾Îļþ

mmapÊÇlinuxϵÄCreateFileMapping£¬ÓÃÀ´Ó³É䲢ͬ²½Îļþ¡£
ÕâÑùµÄ»°£¬±ÈÈçÎÒ×Ô¶¨ÒåÒ»ÖÖÎļþ¸ñʽ£¬°ÑËüдÈëµ½ÎļþÖУ¬ÏÖÔÚÏëÐÞ¸ÄÆäÖеÄÖµ£¬¾Í¿ÉÒÔÓÃÕâ¸öº¯Êý£¬°ÑÎļþÓ³Éäµ½ÄÚ´æÖÐ
È»ºóÓòÙ×÷Êý×éµÄ·½Ê½£¬À´½øÐÐÎļþµÄͬ²½¡£Èç¹û²»ÓÃÕâ¸öº¯Êý¾ÍµÃ£º
1¡¢¶¨ÒåÒ»¸ö½á¹¹Ìå
2¡¢¶¨Òå½á¹¹ÌåÊý×é
3¡¢¶ÁÈ¡Îļþ£¨w+£©
4¡¢ÐÞ¸ÄÎļþ ......

linuxÏÂcÓïÑÔÁ¬½ÓmysqlÊý¾Ý¿â

ÔÚFC8ÖÐĬÈÏ°²×°µÄÓÐmysql£¬Ã»ÓеĻ°¿ÉÒԺܷ½±ãµÄ°²×°Ï¡£
ĬÈϵÄmysqlµÄincludeÎļþĿ¼ÔÚ/usr/include/mysql
ĬÈϵÄmysqlµÄlibÎļþ¼ÐÔÚ/usr/lib/mysql
ÕâÁ½¸öĿ¼ÔÚÎÒÃDZàÒëʱºòÐèÒªµ½¡£
ÎҵIJâÊÔÓõÄC´úÂëΪ£º
££include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
#define CONN_HOST ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ