Hi all,
i have studied this following statement from a book "Each scanning function returns EOF if it encounters end-of-file before any conversion; otherwise it returns the number of successful conversions that were stored."
To test this i have written the following code
i have given directly EOF character Ctrl + Z followed by return key as input. The output is ret = 1 instead of -1. where am i doing the mistake? i know i am doing a mistake some where.Code:#include <stdio.h> int main(int argc, char *argv[]) { char c; int ret=0; ret = scanf("%c",&c); printf("%c\n %d\n",c,ret); printf("%d",EOF); return 0; }
thanks in advance,
regards,
satya



LinkBack URL
About LinkBacks


