Javatpoint Logo
Javatpoint Logo

C fputs() and fgets()

The fputs() and fgets() in C programming are used to write and read string from stream. Let's see examples of writing and reading file using fgets() and fgets() functions.


Writing File : fputs() function

The fputs() function writes a line of characters into file. It outputs string to a stream.

Syntax:

Example:

myfile2.txt

hello c programming

Reading File : fgets() function

The fgets() function reads a line of characters from file. It gets string from a stream.

Syntax:

Example:

Output:

hello c programming
Next TopicC fseek()



Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA