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

c vaϵÁкêµÄ»ù±¾Ó÷¨

 vaϵÁкêµÄÓ÷¨µÄÒ»°ã²½Ö裺
 vsptr(char *format, ...)  //ÇмǴ˴¦µÄ¸ñʽ
 {
    va_list argptr;
    va_start(argptr, format); //ʹµÃargptrÖ¸ÏòÒÔformat¿ªÍ·µÄ´æ´¢¿Õ¼ä
    va_arg(argptr, type);  //È¡´«µÝµÄ²ÎÊý
    ...
    va_end(argptr);    //½áÊø£¬ÊÍ·ÅargptrËùÕ¼ÓõÄÄÚ´æ¿Õ¼ä
}
ÅжÏargptrËùÖ¸ÏòµÄ²ÎÊýÊÇ·ñÒѾ­È¡ÍêÁ˵ķ½·¨£º1-¿ÉÒÔ´«µÝµÄ¸öÊý  2-²ÉÓÃvsprintf/vsnprintfϵÁеĺ¯Êý(¿ÉÒÔ½«ËùÓеIJÎÊýÒ»´ÎÈ¥Íê)£¬¸Ãº¯ÊýµÄ³£ÓÃÓ÷¨ÈçÏÂʾÀý£º
#include<stdio.h>
#include <stdarg.h>
#define bufsize 80
char buffer[bufsize];
int vspf(char *fmt, ...)

 va_list argptr;
 int cnt;
 va_start(argptr, fmt);
 cnt = vsnprintf(buffer,bufsize ,fmt, argptr);
 va_end(argptr);
 return(cnt);

int main(void)

 int inumber = 30;
 float fnumber = 90.0;
 char string[4] = "abc";
 
 vspf("%d %f %s", inumber, fnumber, string);
 
 printf("%s\n", buffer);
 return 0;


Ïà¹ØÎĵµ£º

[ÊÕ²Ø]C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉî²ã̽Ë÷

¸ù±¾Ô­ÒòÔÚÓë×óÖµºÍÓÒÖµ
char a[10]=“hello”;
sizeof(a);//Êý×éÃû×ö×óÖµ£¬¾ßÓÐÊý×éÃûµÄÊôÐÔ£¬ÊÇÒ»¸öÖ¸ÏòÊý×éÊ×µØÖ·µÄ³£Á¿Ö¸Õë
strcpy(a,"abc");//Êý×éÃû×öÓÒÖµ£¬ÍË»¯ÎªÆÕͨµÄÖ¸Õë
Ô­ÎÄÁ´½Ó£º
 http://hi.baidu.com/%D2%C0%BD%A3%D0%F9/blog/item/7bbf36966c92f36a54fb9663.html
×÷ÕߣºËᦻª e ......

CÖкê#ºÍ##µÄÔËÓÃ

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#define f(a,b) a##b
#define g(a)  #a
#define h(a) g(a)
int main()   
{   
    char a = 'a';      
    ......

CÌâÄ¿2

Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ïʽµÄÖµ£¬Òò´Ë£¬Ö±½Ó ......

C/C++ÖеÄÈÕÆÚºÍʱ¼ä time_tÓëstruct tmת»»

 ÕªÒª£º
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch ......

¹ØÓÚcÖÐvolatile¹Ø¼ü×Ö£¨×ªÌù£©

 Ò»¸ö¶¨ÒåΪvolatileµÄ±äÁ¿ÊÇ˵Õâ±äÁ¿¿ÉÄܻᱻÒâÏë²»µ½µØ¸Ä±ä£¬ÕâÑù£¬±àÒëÆ÷¾Í²»»áÈ¥¼ÙÉèÕâ¸ö±äÁ¿µÄÖµÁË¡£¾«È·µØ˵¾ÍÊÇ£¬ÓÅ»¯Æ÷ÔÚÓõ½Õâ¸ö±äÁ¿Ê±±ØÐëÿ´Î¶¼Ð¡ÐĵØÖØжÁÈ¡Õâ¸ö±äÁ¿µÄÖµ£¬¶ø²»ÊÇʹÓñ£´æÔڼĴæÆ÷ÀïµÄ±¸·Ý¡£ÏÂÃæÊÇvolatile±äÁ¿µÄ¼¸¸öÀý×Ó£º
    1). ²¢ÐÐÉ豸µÄÓ²¼þ¼Ä´æÆ÷£¨È磺״̬¼Ä´æÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ