putc writes to logical unit 6, normally the control terminal output.
fputc writes to a logical unit.
These functions write a character to the file associated with a Fortran logical unit bypassing normal Fortran I/O.
Do not mix normal Fortran output with output by these functions on the same unit.
Note that to write any of the special \ escape characters, such as ’\n’ newline, requires compiling with -f77=backslash FORTRAN 77 compatibility option.
The function is called by:
|
INTEGER*4 putc status = putc( char ) |
|||
|
char |
character |
Input |
The character to write to the unit |
|
Return value |
INTEGER*4 |
Output |
status=0: OK status>0: System error code |
Example: putc():
demo% cat tputc.f
character char, s*10 / ’OK by putc’ /
INTEGER*4 putc, status
do i = 1, 10
char = s(i:i)
status = putc( char )
end do
status = putc( ’\n’ )
end
demo% f95 -f77=backslash tputc.f
demo% a.out
OK by putc
demo%
|
The function is called by:
|
INTEGER*4 fputc status = fputc( lunit,char ) |
|||
|
lunit |
INTEGER*4 |
Input |
The unit to write to |
|
char |
character |
Input |
The character to write to the unit |
|
Return value |
INTEGER*4 |
Output |
status=0: OK status>0: System error code |
Example: fputc():
demo% cat tfputc.f
character char, s*11 / ’OK by fputc’ /
INTEGER*4 fputc, status
open( 1, file=’tfputc.data’)
do i = 1, 11
char = s(i:i)
status = fputc( 1, char )
end do
status = fputc( 1, ’\n’ )
end
demo% f95 -f77=backslash tfputc.f
demo% a.out
demo% cat tfputc.data
OK by fputc
demo%
|
See also putc(3S), intro(2), and perror(3F).