Quote:
Originally Posted by asadullah.ansari
You are still using library function getchar() and putchar().

He is asking if i am correct.


Code:
#include "stddef.h"
#include "stdarg.h"
#include "stdlib.h"

extern FILE *Stderr;


int  MyScanf(char *s, const char *fmt, ...)
{
	char *s0;
	va_list ap;
	long L, *Lp;
	int i, *ip, rc = 0;
	va_start(ap, fmt);
	for( ; ; ) {
		for(;;) {
			switch(i = *(unsigned char *)fmt++) {
				case 0:
					goto done;
				case '%':
					break;
				default:
					if (i <= ' ') {
						while(*s <= ' ')
							if (!*s++)
								return rc;
						}
					else if (*s++ != i)
						return rc;
					continue;
				}
			break;
			}
		switch(*fmt++) {
			case 'l':
				if (*fmt != 'd')
					bad(fmt);
				fmt++;
				Lp = va_arg(ap, long*);
				L = strtol(s0 = s, &s, 10);
				if (s > s0) {
					rc++;
					*Lp = L;
					continue;
					}
				return rc;
			case 'd':
				ip = va_arg(ap, int*);
				L = strtol(s0 = s, &s, 10);
				if (s > s0) {
					rc++;
					*ip = (int)L;
					continue;
					}
				return rc;
			default:
				bad(fmt);
			}
		}
 done:
	return rc;
	}
	}

i feel this code is really self explanatary ,

you can explain well