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ºê,ËùÒÔ²ÎÊý²»ÄÜÉùÃ÷Ϊ¼Ä´æÆ÷±äÁ¿»ò×÷Ϊº¯
Ïà¹ØÎĵµ£º
ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔÀ´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
memcached_st *memc;
uint32_t&nbs ......
µÚ7Õ ÄÚ´æ¹ÜÀí
»¶Ó½øÈëÄÚ´æÕâƬÀ×Çø¡£Î°´óµÄBill Gates Ôø¾Ê§ÑÔ£º
640K ought to be enough for everybody
— Bill Gates 1981
³ÌÐòÔ±ÃǾ³£±àдÄÚ´æ¹ÜÀí³ÌÐò£¬ÍùÍùÌáÐĵõµ¨¡£Èç¹û²»Ïë´¥À×£¬Î¨Ò»µÄ½â¾ö°ì·¨¾ÍÊÇ·¢ÏÖËùÓÐDZ·üµÄµØÀײ¢ÇÒÅųýËüÃÇ£¬¶ãÊǶ㲻Á˵ġ£±¾ÕµÄÄÚÈݱÈÒ»°ã½Ì¿ÆÊéµÄÒªÉîÈëµÃ¶à£¬¶ÁÕßÐèϸР......
1. cÓïÑÔÖеÄÕûÊýÀàÐÍÓÐchar, short, int, longµÈ¼¸ÖÖ, ÏÂÃæÊÇCÓïÑÔ¶ÔÿÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ¹æ¶¨:
(a). shortºÍlongÀàÐ͵ij¤¶È²»Ïàͬ
(b). intÀàÐÍͨ³£Í¬¾ßÌå»úÆ÷µÄÎïÀí×Ö³¤Ïàͬ
(c). shortͨ³£ÊÇ16bits, intͨ³£ÊÇ16bits or 32bitsÿÖÖ±àÒëÆ÷¿ÉÒÔ¸ù¾ÝÓ²¼þµÄ²»Í¬×ÔÓÉÈ·¶¨, µ«ÊÇshortºÍint±ØÐë×îÉÙÊÇ16bits, ¶ølongÀàÐͱØÐë× ......
mmapÊÇlinuxϵÄCreateFileMapping£¬ÓÃÀ´Ó³É䲢ͬ²½Îļþ¡£
ÕâÑùµÄ»°£¬±ÈÈçÎÒ×Ô¶¨ÒåÒ»ÖÖÎļþ¸ñʽ£¬°ÑËüдÈëµ½ÎļþÖУ¬ÏÖÔÚÏëÐÞ¸ÄÆäÖеÄÖµ£¬¾Í¿ÉÒÔÓÃÕâ¸öº¯Êý£¬°ÑÎļþÓ³Éäµ½ÄÚ´æÖÐ
È»ºóÓòÙ×÷Êý×éµÄ·½Ê½£¬À´½øÐÐÎļþµÄͬ²½¡£Èç¹û²»ÓÃÕâ¸öº¯Êý¾ÍµÃ£º
1¡¢¶¨ÒåÒ»¸ö½á¹¹Ìå
2¡¢¶¨Òå½á¹¹ÌåÊý×é
3¡¢¶ÁÈ¡Îļþ£¨w+£©
4¡¢ÐÞ¸ÄÎļþ ......
ÔÚ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 ......