Standard Library Functions in C

adplus-dvertising
fputs() Function
Previous Home Next

Description

The C library function, The fputs( ) function writes the contents of the string pointed to by str to the specified stream. The null terminator is not written.

Declaration

Following is the declaration for fputs() function.

int fputs(const char *str, FILE *stream)

Parameters

str - constant character pointer or string that is to be written in the file

stream - pointer to the file in which the data is to be written.

Return Value

The fputs function On success Non negative value and On failure End of file(EOF), setting the error indicator.

Example

#include <stdio.h>

int main ()
{
   FILE *fp;

   fp = fopen("file.txt", "w+");

   fputs("This is c programming.", fp);
   
   fclose(fp);
   
   return(0);
}

Output

This is c programming.
Previous Home Next