top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is the difference between gets and fgets and between puts and fputs in C?

+5 votes
330 views
What is the difference between gets and fgets and between puts and fputs in C?
posted Jan 3, 2016 by anonymous

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

1 Answer

0 votes

gets - It reads data from the standard input and it stops only when it encounters new line character. It does not take care about the length of the buffer. Now safe to use.
fgets - Unlike gets, fgets can read data from standard input as well as from file stream. It has one parameter which takes care about the length of the buffer. It reads buffer up to maxsize - 1 bytes.
puts - This function is used to write null terminated string onto console.
fputs - This function is used to write null terminated string onto console or file stream.

This is what I know about all these function.

answer Jan 3, 2016 by Vikram Singh
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...