From 5cb273d927870b84b33f90d2e5cb50f1ff565411 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Mon, 17 Sep 2012 21:58:09 +0430 Subject: [PATCH] stdio.h: a string of length zero for %s is a failure --- scanf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scanf.c b/scanf.c index 7e7e1fd..e7a2313 100644 --- a/scanf.c +++ b/scanf.c @@ -69,13 +69,13 @@ static int iint(FILE *fp, void *dst, int l) static int istr(FILE *fp, char *dst) { - long n = 0; + char *d = dst; int c; while ((c = ic(fp)) != EOF && !isspace(c)) - *dst++ = c; - *dst = '\0'; + *d++ = c; + *d = '\0'; ungetc(c, fp); - return 0; + return d == dst; } int vfscanf(FILE *fp, char *fmt, va_list ap) -- 2.11.4.GIT