xref: /plan9-contrib/sys/src/libstdio/snprintf.c (revision a84536681645e23c630ce4ef2e5c3b284d4c590b)
1 /*
2  * pANS stdio -- sprintf
3  */
4 #include "iolib.h"
5 int snprintf(char *buf, int nbuf, const char *fmt, ...){
6 	int n;
7 	va_list args;
8 	FILE *f=sopenw();
9 	if(f==NULL)
10 		return 0;
11 	setvbuf(f, buf, _IOFBF, nbuf);
12 	va_start(args, fmt);
13 	n=vfprintf(f, fmt, args);
14 	va_end(args);
15 	sclose(f);
16 	return n;
17 }
18