FPUTC

Portability Function: Writes a character to the file specified by a Fortran external unit, bypassing normal Fortran input/output.

Module

USE IFPORT

Syntax

result = FPUTC (lunit,char)

lunit

(Input) INTEGER(4). Unit number of a file.

char

(Output) Character*(*). Variable whose value is to be written to the file corresponding to lunit.

Results

The result type is INTEGER(4). The result is zero if the write was successful; otherwise, an error code, such as:

EINVAL - The specified unit is invalid (either not already open, or an invalid unit number)

If you use WRITE, READ, or any other Fortran I/O statements with lunit, be sure to read Building Applications: Input and Output With Portability Routines.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

Example

use IFPORT

integer*4 lunit, i4

character*26 string

character*1 char1

lunit = 1

open (lunit,file = 'fputc.dat')

do i = 1,26

char1 = char(123-i)

i4 = fputc(1,char1) !make valid writes

if (i4.ne.0) iflag = 1

enddo

rewind (1)

read (1,'(a)') string

print *, string

See Also