# doubt between fscanf and fgets



## bijay_ps (Mar 31, 2011)

whats the difference between fscanf and fgets in file handling(In C)?


----------



## arpanmukherjee1 (Mar 31, 2011)

fscanf does not perform bounds checking. fgets is likely going to be the better choice. You can then use sscanf() to evaluate it.

more info
IBM TPF Product Information Center
fscanf - C++ Reference
fgets - C++ Reference
scanf vs fgets?

BTW one more thing, never use scanf for input, use cin. Google it up if u want to know why, too many reasons for me to type


----------



## QwertyManiac (Apr 1, 2011)

Why suggest std::cin when the OP is using C, and confuse him?


----------



## arpanmukherjee1 (Apr 1, 2011)

^^ yes i thought it too 

but the advantage(s) of C++ over C must be kept in mind


----------



## bijay_ps (Apr 1, 2011)

thanks guys....


----------



## Liverpool_fan (Apr 1, 2011)

arpanmukherjee1 said:


> but the advantage(s) of C++ over C must be kept in mind


???
Not sure how std::cin can be an advantage of C++ over C? Only advantage I can think of that you have to specify the format for the input in scanf which is not needed in std::cin. However both exhibit similar behaviour since they are usually implemented as line buffered.


----------



## arpanmukherjee1 (Apr 1, 2011)

^^ yes that, i'am sorry about the post.
i should have explained it. 
reading this post now, i sound a lot like my coll professors

u explained it very well. thankyou


----------

