第二章 2-2 函数的构造

来源:互联网 发布:淘宝墙上挂的饰品 编辑:程序博客网 时间:2024/05/17 08:54

c语言中的一些高级特性

int my_printf(const char * szFormat,...){    int iReturn;    va_list pArgs;    va_start(pArgs,szFormat);    iReturn = vprintf(szFormat,pArgs);    va_end(pArgs);    return iReturn;}int main(){    int a = 12;    char szBuffer[100];    int x = 100, y = 200, z = 300;    printf("hello %d, %d, %d\n",x,y,z);    my_printf("hello %d, %d\n",x,y);    return 0;}

在windows程序设计中的应用

int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat,...){TCHAR szBuffer[1024];va_list pArgList;va_start(pArgList,szFormat);_vsntprintf(szBuffer,sizeof(szBuffer)/sizeof(TCHAR),szFormat,pArgList);va_end(pArgList);return MessageBox(NULL,szBuffer,szCaption,MB_OK | MB_ICONINFORMATION);}
0 0
原创粉丝点击