fputwc - Linux


Overview

fputwc writes a wide character to a file or stream. It acts as a wrapper function to fputc.

Syntax

int fputwc(wchar_t wc, FILE *stream);

Options/Flags

None

Examples

Example 1: Write a wide character to a file

#include <stdio.h>
#include <wchar.h>

int main() {
    FILE *fp = fopen("file.txt", "w");
    fputwc(L'あ', fp);
    fclose(fp);
}

Common Issues

  • Ensure the file is opened with the correct mode for writing wide characters.
  • The file stream must be valid and writable.

Integration

fputwc can be used in conjunction with other I/O functions, such as fgetcwc, to read and write wide characters from files or streams.

Related Commands

  • fwrite
  • fprintf
  • fgetc
  • fputc