FAT | RFS | XFS

fputs()

PROTOTYPE

#include <stdio.h>

int fputs(const char *string, FILE *file);

DESCRIPTION

fputs() writes the null-terminated string indicated by string to the open regular file specified by file at its current position, or end if open in append mode. All characters up to the ending null are written as if by fputc(). Neither the terminating null nor an ending newline character are written.

If successful, fputs() updates the file’s status change and data modification timestamps, marks its metadata as dirty, advances its current position, and returns a non-negative number. Otherwise, it sets errno and the file’s error indicator, and returns EOF.

ERROR CODES

EBADF file is not the handle of a file open in write or append mode.
EFAULT string equals NULL.
ENOSPC The volume is full.
ENXIO The volume has been removed.
EROFS The volume is read-only.

EXAMPLE

FILE *file;

/*-----------------------------------------------------------------*/
/* Open file for writing.                                          */
/*-----------------------------------------------------------------*/
file = fopen("/flash/temp.txt", "w");
if (file == NULL)
  return -1;

/*-----------------------------------------------------------------*/
/* Write string to stream.                                         */
/*-----------------------------------------------------------------*/
if (fputs("Hello World!\n", file) == EOF)
  return -1;