shithub: riscv

ref: c33fc43408cb22d606d2f621c34a5748cb0e2bc5
dir: /sys/src/libstdio/snprintf.c/

View raw version
/*
 * pANS stdio -- sprintf
 */
#include "iolib.h"
int snprintf(char *buf, int nbuf, const char *fmt, ...){
	int n;
	va_list args;
	FILE *f=sopenw();
	if(f==NULL)
		return 0;
	setvbuf(f, buf, _IOFBF, nbuf);
	va_start(args, fmt);
	n=vfprintf(f, fmt, args);
	va_end(args);
	sclose(f);
	return n;
}