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ºê,ËùÒÔ²ÎÊý²»ÄÜÉùÃ÷Ϊ¼Ä´æÆ÷±äÁ¿»ò×÷Ϊº¯
Ïà¹ØÎĵµ£º
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼Æ ......
ÒòΪÏîÄ¿ÒªÇó£¬ÖÆ×÷µÄÒ»¸ö¶àÎļþÉÏ´«£¬²¢ÏÔʾ½ø¶ÈÌõÒ»¶Î´úÂë(vs2005»·¾³)¡£
(ֻΪ´ÖÂÔµÄʵÏÖ£¬´úÂë²¢²»¹æ·¶)
µ±¶à¸öÎļþÉÏ´«µÄʱºò£¬ÐèÒªÒÀ´Î¶ÓÁÐÐÎʽһ¸ö¸öÉÏ´«£¬µ±ÉÏ´«Ä³¸öÎļþµÄʱºò£¬Ëø¶¨½ø³Ì£¬ÉÏ´«Íê±ÏÔÙ¿ªÆôËø¡£
ÔÚÖ÷ÀàÖеÄÉÏ´«°´Å¥Ê¼þ´úÂë:
//
»ñÈ¡openFileDialog¿Ø¼þÑ¡ÔñµÄÎļþÃûÊý×é(openFileDialog¿É ......
#include <iostream>
#include <cstdlib>
using namespace std;
class Foo
{
public:
Foo(int ii):i(ii){}
int getInt(){return i;}
private:
int i;
};
class Bar
{
public:
static int FooVal(){c++; return f.getInt();}
int callsFooVal(){return c;}
private:
s ......
2.2 ½â¾ö¿É²âÐÔÎÊÌâ
ÉÏÒ»½Ú¾ßÌå·ÖÎöÁ˿ɲâÐÔÎÊÌ⣬½ÓÏÂÀ´£¬ÎÒÃÇÀ´¿´¿´ÈçºÎ½â¾öÕâЩÎÊÌâ¡£ÏÂͼÖУ¬²ÊÉ«µÄ²¿·ÖÊÇÐèÒª½â¾öµÄ¿É²âÐԵľßÌåµÄÎÊÌâ¡£
ÓëÆäËû´úÂë¸ôÀë
ΪÁËÌá¸ßЧÂÊ£¬Ó¦¸ÃÒ»´ÎÐÔ½«Ò»Î»¹¤³Ìʦ¸ºÔðµÄ²âÊÔÈÎÎñ¸ôÀë³öÀ´¡£¸ôÀëʱ£¬Ó¦°ÑÔ´Îļþ·ÖΪÈýÀࣺ± ......
ʵÑéÒªÇó£º
1.±àд»ùÓÚTCPÐÒéµÄͨÐųÌÐò£¬°üÀ¨ServerÓëClientÁ½¸ö²¿·Ö¡£ÊµÏÖ»ØÉù³ÌÐò£º¼´¿Í»§¶Ë·¢ËÍÏûÏ¢£¬·þÎñÆ÷¶Ë½«ÊÕµ½µÄÏûÏ¢ÔÑù»áË͸ø¿Í»§¶Ë¡£
2.ÔÚµ¥»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»
3.ÔÚ¶à»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»£¨ChatServerÖ»ÐèÔËÐÐÔÚһ̨Ö÷»úÉÏ£¬ChatClient¿ÉÔÚÆäËüÖ÷»úÉÏÔËÐУ¨ÒªÖªµÀChatServerËùÔ ......