1. Home >
  2. Apps >
  3. Groups >

What is - while(scanf("%d %d",&n,&m)!=EOF) ?

Question asked by lit-857 in #Coffee Room on Apr 12, 2013
lit-857 · Apr 12, 2013
Rank D3 - MASTER
wts EOF AND IS SCANF returen values? Posted in: #Coffee Room
Whats In Name
Whats In Name · Apr 12, 2013
Rank B3 - LEADER
scanf returns the number of items assigned,EOF means end-of-file and has value -1,so this statement probably means run the loop 2 times.

*Please correct me,if I am wrong
rahul69 · Apr 12, 2013
Rank B2 - LEADER
wts EOF AND IS SCANF returen values?
This statement simply means keep on scanning the values of m and n until End of File is reached.
Scanf returns number of variables scanned normally but it returns EOF if End of File is reached before variables could be scanned.😀
Prateek Gupta
Prateek Gupta · Apr 18, 2013
scanf :- used to scan the values.
EOF:- indicates the End Of File.
!= :- relational operator (not equal to)
this can be understood like this :-
keep scanning the values in variables n and m from the file until EOF has not been found.

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up