sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

confirm.c (347B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdarg.h>
      3 #include <ctype.h>
      4 
      5 #include "../util.h"
      6 
      7 int
      8 confirm(const char *fmt, ...)
      9 {
     10 	int c, ans;
     11 	va_list ap;
     12 
     13 	va_start(ap, fmt);
     14 	xvprintf(fmt, ap);
     15 	va_end(ap);
     16 
     17 	c = getchar();
     18 	ans = (c == 'y' || c == 'Y');
     19 	while (c != '\n' && c != EOF)
     20 		c = getchar();
     21 	return ans;
     22 }