]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/fputc.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / fputc.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: FPUTC, write character, stream mode, stream mode, write character, file operation, write character
7
8 .. _fputc:
9
10 FPUTC --- Write a single character in stream mode
11 *************************************************
12
13 .. function:: FPUTC(UNIT, C)
14
15 Write a single character in stream mode by bypassing normal formatted
16 output. Stream I/O should not be mixed with normal record-oriented
17 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
18
19 :param UNIT:
20 The type shall be ``INTEGER``.
21
22 :param C:
23 The type shall be ``CHARACTER`` and of default
24 kind.
25
26 :param STATUS:
27 (Optional) status flag of type ``INTEGER``.
28 Returns 0 on success, -1 on end-of-file and a system specific positive
29 error code otherwise.
30
31 Standard:
32 GNU extension
33
34 Class:
35 Subroutine, function
36
37 Syntax:
38 .. code-block:: fortran
39
40 CALL FPUTC(UNIT, C [, STATUS])
41 STATUS = FPUTC(UNIT, C)
42
43 Example:
44 .. code-block:: fortran
45
46 PROGRAM test_fputc
47 CHARACTER(len=10) :: str = "gfortran"
48 INTEGER :: fd = 42, i
49
50 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
51 DO i = 1, len_trim(str)
52 CALL fputc(fd, str(i:i))
53 END DO
54 CLOSE(fd)
55 END PROGRAM
56
57 See also:
58 :ref:`FPUT`,
59 :ref:`FGET`,
60 :ref:`FGETC`