top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What does scanf() returns in c language?

+4 votes
309 views
What does scanf() returns in c language?
posted Apr 3, 2016 by Shahsikant Dwivedi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes
 
Best answer

Number of successful read.
For example
int i;
char ch[100];
scanf("%d"%s", i, ch);

If scanf reads successfully both the variables then it returns 2.

answer Apr 3, 2016 by Harshita
+1 vote

NAME
scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf

   ...

RETURN VALUE
These functions return the number of input items successfully matched
and assigned, which can be fewer than provided for, or even zero in the
event of an early matching failure.

   The value EOF is returned if the end of input is reached before  either
   the  first  successful conversion or a matching failure occurs.  EOF is
   also returned if a read error occurs, in which case the error indicator
   for  the  stream  (see ferror(3)) is set, and errno is set indicate the
   error.
answer Apr 5, 2016 by Shubham Singh
...