Demo entry 6632281

showstr

   

Submitted by anonymous on Jul 24, 2017 at 08:25
Language: C. Code size: 436 Bytes.

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

void showstr(char*, ...);

char* p1 = "this is a c program";
char* p2 = "welcome to c";
char* p3 = "hello world";

main()
{
	showstr(p1, p2, p3, 0);
}

void showstr(char* str, ...) {
	va_list ap;
	char* next_arg = 0;

	printf("%s\n", str);
	va_start(ap, str);

	while((next_arg = va_arg(ap, char*)) != 0) 
		printf("%s\n", next_arg);
	
	va_end(ap);
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).