编辑代码

#include <stdio.h>
#include <stdarg.h>

void my_printf(const char *format, ...)
{
	va_list ap;
	char buf[200];
	char n;
    char i;
	
	va_start(ap, format);
	
	n = vsprintf(buf,format,ap);
	
	va_end(ap);
	
	for(i = 0;i < n;i++)
    {
        putchar(buf[i]);
    }
}

void my_printf2(const char *format, ...)
{
	va_list ap;
	
	va_start(ap, format);
	
	vprintf(format,ap);
	
	va_end(ap);
}

int main () {
    //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
    int i,n;

    char *p[] = {"hello","world","c_languge","!"};
    
    n = sizeof(p)/sizeof(*p);

    for(i = 0;i < n;i++)
    {
        my_printf("#%d %s\n",i,p[i]);
    }
    my_printf("#%d %s %s %s %s\n",i,p[0],p[1],p[2],p[3]);

    for(i = 0;i < n;i++)
    {
        my_printf2("#%d->%s\n",i,p[i]);
    }
    my_printf2("#%d->%s %s %s %s\n",i,p[0],p[1],p[2],p[3]);

	return 0;
}