Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
getc(3S)							      getc(3S)

NAME
       getc(), getc_unlocked(),	getchar(), getchar_unlocked(), fgetc(),	getw()
       - get character or word from a stream file

SYNOPSIS
   Obsolescent Interface
DESCRIPTION
       Returns the next	character (i.e., byte) from the	named input
		      stream, as an unsigned character converted to  an	 inte-
		      ger.   It	also moves the file pointer, if	defined, ahead
		      one character in stream.	is defined as and are  defined
		      both as macros and as functions.

       Same as	      but  is  a function rather than a	macro.	is slower than
		      but it takes less	space per invocation and its name  can
		      be passed	as an argument to a function.

       returns the next	word (i.e.,
		      in C) from the named input stream.  increments the asso-
		      ciated file pointer, if defined, to point	 to  the  next
		      word.   The size of a word is the	size of	an integer and
		      varies from machine  to  machine.	  assumes  no  special
		      alignment	in the file.

       and  are	 identical  to and respectively	except they do not perform any
       internal	locking	of the stream for multithreaded	applications.

   Obsolescent Interface
       gets character or word from a stream file.

APPLICATION USAGE
       and interfaces should be	used by	multithread  applications  which  have
       already	used  to  acquire  a mutual exclusion lock for the stream (see
       flockfile(3S)).

       After or	is applied to a	stream,	the stream becomes byte-oriented  (see
       orientation(5)).

RETURN VALUE
       Upon  successful	 completion,  and  return the next byte	from the input
       stream pointed to by stream for If the stream is	 at  end-of-file,  the
       end-of-file  indicator for the stream is	set and	EOF is returned.  If a
       read error occurs, the error indicator for the stream is	set, is	set to
       indicate	the error, and EOF is returned.

       Upon  successful	completion, return the next word from the input	stream
       pointed to by stream.  If the stream is at end-of-file, the end-of-file
       indicator  for  the  stream is set and return EOF.  If a	read error oc-
       curs, the error indicator for the stream	is set,	and return EOF and set
       to indicate the error.

       and  can	 be used to distinguish	between	an error condition and an end-
       of-file condition.

ERRORS
       and fail	if data	needs to be read into the stream's buffer, and:

	      [EAGAIN]	     The flag is set for the file descriptor  underly-
			     ing  stream  and  the process would be delayed in
			     the read operation.

	      [EBADF]	     The file descriptor underlying stream  is	not  a
			     valid file	descriptor open	for reading.

	      [EINTR]	     The  read operation was terminated	due to the re-
			     ceipt of a	signal,	and either no data was	trans-
			     ferred or the implementation does not report par-
			     tial transfer for this file.

	      [EIO]	     A physical	I/O error has occurred,	or the process
			     is	 a  member  of a background process and	is at-
			     tempting to read from its	controlling  terminal,
			     and  either  the  process is ignoring or blocking
			     the signal	or the process group of	the process is
			     orphaned.

       Additional values may be	set by the underlying function (see read(2)).

WARNINGS
       and  are	 implemented  both as library functions	and macros.  The macro
       versions, which are used	by default, are	defined	in To obtain  the  li-
       brary  function either use a to remove the macro	definition or, if com-
       piling in ANSI-C	mode, enclose the function name	in parenthesis or  use
       the  function address.  The following example illustrates each of these
       methods :

       If the integer value returned by	or is stored into a character variable
       then  compared  against	the  integer constant the comparison may never
       succeed because sign-extension of a character on	widening to integer is
       machine-dependent.

       The macro version of incorrectly	treats a stream	argument with side ef-
       fects.  In particular, does not work sensibly.  The function version of
       or should be used instead.

       Because of possible differences in word length and byte ordering, files
       written using are machine-dependent, and	may be unreadable by on	a dif-
       ferent processor.

   Reentrant Interfaces
       If is defined before including the locked versions of the library func-
       tions for and are used by default.

       is an obsolescent interface supported only for compatibility  with  ex-
       isting DCE applications.	New multithreaded applications should use

SEE ALSO
       fclose(3S),  ferror(3S),	flockfile(3S), fopen(3S), fread(3S), gets(3S),
       putc(3S), read(2), scanf(3S), orientation(5), thread_safety(5).

STANDARDS CONFORMANCE
								      getc(3S)

NAME | SYNOPSIS | DESCRIPTION | APPLICATION USAGE | RETURN VALUE | ERRORS | WARNINGS | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=getc&sektion=3s&manpath=HP-UX+11.22>

home | help