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ºê,ËùÒÔ²ÎÊý²»ÄÜÉùÃ÷Ϊ¼Ä´æÆ÷±äÁ¿»ò×÷Ϊº¯
Ïà¹ØÎĵµ£º
/*±¾ÎÄÑ¡×Ô²©´´linuxʵÑéÖ¸µ¼Êé
*Áô×Å×Ô¼ºÑ§Ï°Ö®ÓÃ
*ÔÚÕâÀï±£´æ×Å£¬·ÖÏíÒ»ÏÂ*/
VI ¼ò½é
vi ÊÇ Linux/Unix ÊÀ½çÀKΪÆÕ±éµÄ¿ÉÊÓ»¯µÄÈ«ÆÁÄ»Îı¾±à¼Æ÷(visual edit),¼¸ºõ¿É
ÒÔ˵ÈκÎһ̨ Linux/Unix »úÆ÷¶¼»áÌṩÕâ¸öÈí¼þ¡£
vi ÓÐÈýÖÖ״̬,¼´±à¼·½Ê½¡¢²åÈ뷽ʽºÍÃüÁî·½Ê ......
ÎÊÌâÃèÊö£ºÐ´Ò»¸öº¯Êý£¬½ÓÊÜÒ»¸öÕûÊý£¨¼Ù¶¨ÓÃint±íʾ£©£¬Êä³ö¸ÃÕûÊýµÄ×Ö·û´®ÐÎʽ¡£²ÉÓÃÈçϺ¯ÊýÔÐÍ£º
void itoa ( int val, buf* );
ÕâÀï¼Ù¶¨buf×ã¹»´óÒÔÈÝÄÉÈκÎintÀàÐÍÊýÖµµÄ×Ö·û´®¡£
Õâ¸öÎÊÌ⣬³õ¿´ºÃÏñûÓÐʲôÄѶȡ£Èç¹ûÊÇ0£¬¾ÍÖ±½ÓÊä³ö'0'£»Èç¹ûÊÇÕýÊý£¬¾Íͨ¹ýÈ¡Ä£(%)ºÍÇóÉÌ(/)ÔËËã¿ÉÒÔÖðλȡµÃ¸ÃÕûÊýµÄÊý×Ö£¬²¢° ......
µÚ7Õ ÄÚ´æ¹ÜÀí
»¶Ó½øÈëÄÚ´æÕâƬÀ×Çø¡£Î°´óµÄBill Gates Ôø¾Ê§ÑÔ£º
640K ought to be enough for everybody
— Bill Gates 1981
³ÌÐòÔ±ÃǾ³£±àдÄÚ´æ¹ÜÀí³ÌÐò£¬ÍùÍùÌáÐĵõµ¨¡£Èç¹û²»Ïë´¥À×£¬Î¨Ò»µÄ½â¾ö°ì·¨¾ÍÊÇ·¢ÏÖËùÓÐDZ·üµÄµØÀײ¢ÇÒÅųýËüÃÇ£¬¶ãÊǶ㲻Á˵ġ£±¾ÕµÄÄÚÈݱÈÒ»°ã½Ì¿ÆÊéµÄÒªÉîÈëµÃ¶à£¬¶ÁÕßÐèϸР......
Ò»£® ºÎν¿É±ä²ÎÊý
int printf( const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔÐÍ£¬ËüµÄ²ÎÊýÖоÍÓй̶¨²ÎÊýformatºÍ¿É±ä²ÎÊý£¨Óᱡ¡±±íʾ£©¡£
¶øÎÒÃÇÓÖ¿ÉÒÔÓø÷ÖÖ·½Ê½À´µ÷ÓÃprintf,Èç:
printf("%d",value);
printf("%s",str);
printf("the number is %d ,st ......
ÔÚ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 ......