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

C¿É±ä²ÎÊýº¯Êý ʵÏÖ

 Cº¯ÊýÒªÔÚ³ÌÐòÖÐÓõ½ÒÔÏÂÕâЩºê:
void va_start( va_list arg_ptr, prev_param );
type va_arg( va_list arg_ptr, type );
void va_end( va_list arg_ptr );
va_list:ÓÃÀ´±£´æºêva_start¡¢va_argºÍva_endËùÐèÐÅÏ¢µÄÒ»ÖÖÀàÐÍ¡£ÎªÁË·ÃÎʱ䳤²ÎÊýÁбíÖеIJÎÊý£¬±ØÐëÉùÃ÷
             va_listÀàÐ͵ÄÒ»¸ö¶ÔÏó       ¶¨Ò壺 typedef char *  va_list;
va_start:·ÃÎʱ䳤²ÎÊýÁбíÖеIJÎÊý֮ǰʹÓõĺ꣬Ëü³õʼ»¯ÓÃva_listÉùÃ÷µÄ¶ÔÏ󣬳õʼ»¯½á¹û¹©ºêva_argºÍ
               va_endʹÓã»
va_arg: Õ¹¿ª³ÉÒ»¸ö±í´ïʽµÄºê£¬¸Ã±í´ïʽ¾ßÓб䳤²ÎÊýÁбíÖÐÏÂÒ»¸ö²ÎÊýµÄÖµºÍÀàÐÍ¡£Ã¿´Îµ÷ÓÃva_arg¶¼»áÐÞ¸Ä
              ÓÃva_listÉùÃ÷µÄ¶ÔÏ󣬴Ӷøʹ¸Ã¶ÔÏóÖ¸Ïò²ÎÊýÁбíÖеÄÏÂÒ»¸ö²ÎÊý£»
va_end:¸Ãºêʹ³ÌÐòÄܹ»´Ó±ä³¤²ÎÊýÁбíÓúêva_startÒýÓõĺ¯ÊýÖÐÕý³£·µ»Ø¡£
vaÔÚÕâÀïÊÇvariable-argument(¿É±ä²ÎÊý)µÄÒâ˼.
ÕâЩºê¶¨ÒåÔÚstdarg.hÖÐ,ËùÒÔÓõ½¿É±ä²ÎÊýµÄ³ÌÐòÓ¦¸Ã°üº¬Õâ¸öÍ·Îļþ.ÏÂÃæÎÒÃÇдһ¸ö¼òµ¥µÄ¿É±ä²ÎÊýµÄº¯Êý,¸Äº¯ÊýÖÁÉÙÓÐÒ»¸öÕûÊý²ÎÊý,µÚ¶þ¸ö²ÎÊýÒ²ÊÇÕûÊý,ÊÇ¿ÉÑ¡µÄ.º¯ÊýÖ»ÊÇ´òÓ¡ÕâÁ½¸ö²ÎÊýµÄÖµ.
#include <stdio.h>;
#include <string.h>;
#include <stdarg.h>;
/* ANSI±ê×¼ÐÎʽµÄÉùÃ÷·½Ê½£¬À¨ºÅÄÚµÄÊ¡ÂԺűíʾ¿ÉÑ¡²ÎÊý */
int demo(char *msg, ... )
{
va_list argp; /* ¶¨Òå±£´æº¯Êý²ÎÊýµÄ½á¹¹ */
int argno = 0; /* ¼Í¼²ÎÊý¸öÊý */
char *para; /* ´æ·ÅÈ¡³öµÄ×Ö·û´®²ÎÊý */

/* argpÖ¸Ïò´«ÈëµÄµÚÒ»¸ö¿ÉÑ¡²ÎÊý£¬ msgÊÇ×îºóÒ»¸öÈ·¶¨µÄ²ÎÊý */
va_start( argp, msg );

while (1)
{
para = va_arg( argp, char *); /* È¡³öµ±Ç°µÄ²ÎÊý£¬ÀàÐÍΪchar *. */
if ( strcmp( para, "\0") == 0 )
/* ²ÉÓÿմ®Ö¸Ê¾²ÎÊýÊäÈë½áÊø */
break;
printf("Parameter #%d is: %s\n", argno, para);
argno++;
}
va_end( argp ); /* ½


Ïà¹ØÎĵµ£º

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(7)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1.       fgetcº¯Êý
fgetcº¯ÊýµÄ¹¦ÄÜÊÇ´ÓÁ÷ÖжÁÈ¡×Ö·û£¬ÆäÓ÷¨ÊÇ£ºint fgetc(FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h ......

C/C++Èí¼þ¹¤³Ìʦ¾ÍÒµÇóÖ°ÊÖ²á½ÚÑ¡¶þ

 5¡¢#defineºê¶¨Òå¡£ºêÖ»ÊǼòµ¥µÄÎı¾Ìæ»»£¬ºÜÈÝÒ×ÒýÆðÆçÒå¡£
#include <stdio.h>
#define CONS(a,b) (int)(a##e##b)
#define STR(s) #s
int main()
{
   printf(STR(vck));
   printf("\n");
   printf("%d\n",CONS(2,3));
   return 0; ......

ÓÃCдµÄ¶ÁÈ¡´úÂëÐÐÊý¡£

½ñÌìÎÞÊ£¬ÔÚÂÛ̳ÉÏÒ»Ö±¿´Ìù×Ó£¬ºÜÉÙ¶¯ÊÖʵ¼ù£¬½ñÌìÊÔ×ÅдÁËÒ»¸ö¶ÁÈ¡Ô´³ÌÐò´úÂëÐÐÊýµÄÀý×Ó£º
ÏÖÔڵĴúÂëÈçÏ£¬¿ÉÄÜ»¹Óв»ÍêÉƵĵط½£¬ÒÔºóÔٸĽø£º
#include <stdio.h>
#define CHARCOUNT 255
#define CON 6 /*µ¥ÐÐ×¢ÊÍ×îÉÙµÄʱºò*/
int realLength = 0;
/*
* function name: strCount
* function : count ......

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(13)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1.       mallocº¯Êý
mallocº¯ÊýµÄ¹¦ÄÜÊÇÄÚ´æ·ÖÅ亯Êý£¬ÆäÓ÷¨Îª£ºvoid *malloc(unsigned size);³ÌÐòʵÀýÈçÏ£º
#include <stdio.h>
#i ......

CÅжÏÎļþ´æÔÚ

 Óú¯Êýaccess£¬Í·ÎļþÊÇio.h£¬Ô­ÐÍ£º
  
int   access(const   char   *filename,   int   amode);
amode²ÎÊýΪ0ʱ±íʾ¼ì²éÎļþµÄ´æÔÚÐÔ£¬Èç¹ûÎļþ´æÔÚ£¬·µ»Ø0£¬²»´æÔÚ£¬·µ»Ø-1¡£
Õâ¸öº¯Êý»¹¿ÉÒÔ¼ì²éÆäËüÎļþÊôÐÔ£º
06   &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ