intro(3)
NAME
intro − introduction to the standard C library subroutines
SYNTAX
#include <stdio.h>
DESCRIPTION
This section describes the various library subroutines and then lists those subroutines that are grouped together with the standard C library. All library subroutines are identified by the section number at the top of the page. The subroutines that are grouped together with the standard C library are those from sections 3, 3j, 3s, and 3v.
The library sections numbers and their corresponding meaning are:
(3) These functions, together with those of Section 2 and those marked (3s), constitute the /lib/libc.a library, which is automatically loaded by the cc C compiler and the Fortran f77 compiler. Declarations for some of these functions may be obtained from include files indicated on the appropriate pages. The ld link editor automatically searches this library when the −lc option is specified.
(3j) These functions constitute the job control subroutines, which are in /usr/lib/libjobs.a (jobs library). For further information, read intro(3j).
(3s) These functions constitute the “standard I/O package,” which are in the /lib/libc.a library. Declarations for these functions may be obtained from the <stdio.h> include file. For further information, see stdio(3s).
(3v) These functions constitute the SYSTEM V subroutines, which are in the /lib/libcV.a library. The link editor searches this library when the −lcV option is specified. For further information about the SYSTEM V programming environment, see cc(1).
(3f) These functions constitute the Fortran library subroutines. For further information, see intro(3f).
(3m) These functions constitute the Math library subroutines. For further information, see intro(3m).
(3n) These functions constitute the internet network subroutines. For further information, read intro(3n).
(3x) These functions, which have not been given a distinctive caption, constitute the miscellaneous libraries. For further information, read intro(3x).
| Standard C Library | Manual | |
| Subroutines | Description | Page |
| a64l | Convert long integer and base-64 ASCII string | a64l(3) |
| abort | Generate IOT fault | abort(3) |
| abs | Integer absolute value | abs(3) |
| asctime | Convert date and time | ctime(3) |
| asctime | Convert date and time (SYSTEM V) | ctime(3v) |
| atof | Convert ASCII to numbers | atof(3) |
| atoi | Convert ASCII to numbers | atof(3) |
| atol | Convert ASCII to numbers | atof(3) |
| bcmp | Compare strings of bytes | bstring(3) |
| bcopy | Copy strings of bytes | bstring(3) |
| bsearch | Binary search sorted table | bsearch(3) |
| bzero | Place zero bytes to string | bstring(3) |
| calloc | Main memory allocator | malloc(3) |
| clock | Report CPU time used | clock(3) |
| closedir | Directory operation | directory(3) |
| closelog | Control system log | syslog(3) |
| clrerr | Stream status inquiry | ferror(3s) |
| crypt | Password encryption | crypt(3) |
| ctermid | Generate terminal file name | ctermid(3s) |
| ctime | Convert date and time | ctime(3) |
| ctime | Convert date and time (SYSTEM V) | ctime(3v) |
| cuserid | Get user login name of the | cuserid(3s) |
| dial | Establish terminal line connection | dial(3) |
| drand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| ecvt | Output conversion | ecvt(3) |
| edata | Last locations in program | end(3) |
| encrypt | Password encryption | crypt(3) |
| end | Last locations in program | end(3) |
| endfsent | Get file system descriptor | getfsent(3) |
| endgrent | Get group file entry | getgrent(3) |
| endpwent | Get password entry | getpwent(3) |
| endutent | Access utmp file entry | getut(3) |
| erand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| etext | Last locations in program | end(3) |
| fclose | Close a stream | fclose(3s) |
| fcvt | Output conversion | ecvt(3) |
| fdopen | Open a stream | fopen(3s) |
| feof | Stream status inquiry | ferror(3s) |
| ferror | Stream status inquiry | ferror(3s) |
| fflush | Flush a stream | fclose(3s) |
| ffs | Find first bit in string | bstring(3) |
| fgetc | Get character from stream | getc(3s) |
| fgetgrent | Get group file entry | getgrent(3) |
| fgetpwent | Get password file entry | getpwent(3) |
| fgets | Get string from stream | gets(3s) |
| fileno | Stream status inquiry | ferror(3s) |
| fopen | Open a stream | fopen(3s) |
| fprintf | Formatted output conversion | printf(3s) |
| fputc | Write character to Fortran logical unit | putc(3s) |
| fputs | Put string on stream | puts(3s) |
| fread | Buffered binary input/output | fread(3s) |
| free | Main memory allocator | malloc(3) |
| freopen | Open a stream | fopen(3s) |
| frexp | Split into mantissa and exponent | frexp(3) |
| fscanf | Formatted input conversion | scanf(3s) |
| fseek | Reposition stream | fseek(3s) |
| ftell | Reposition stream | fseek(3s) |
| ftok | Standard interprocess communication package | stdipc(3) |
| ftw | Walk file tree | ftw(3) |
| fwrite | Buffered binary input/output | fread(3s) |
| gcvt | Output conversion | ecvt(3) |
| getc | Get character/word from stream | getc(3s) |
| getchar | Get character/word from stream | getc(3s) |
| getcwd | Get path/name of current working directory | getcwd(3) |
| getenv | Value for environment name | getenv(3) |
| getfsent | Get file system descriptor file entry | getfsent(3) |
| getfsfile | Get file system descriptor file entry | getfsent(3) |
| getfsspec | Get file system descriptor file entry | getfsent(3) |
| getgrent | Get group file entry | getgrent(3) |
| getgrgid | Get group file entry | getgrent(3) |
| getgrnam | Get group file entry | getgrent(3) |
| getlogin | Get login name | getlogin(3) |
| getopt | Get option letter from argument vector | getopt(3) |
| getpass | Read a password | getpass(3) |
| getpw | Get name from UID | getpw(3) |
| getpwent | Get password file entry | getpwent(3) |
| getpwnam | Get password file entry | getpwent(3) |
| getpwuid | Get password file entry | getpwent(3) |
| gets | Get string from stream | gets(3s) |
| getutent | Access utmp file entry | getut(3) |
| getutid | Access utmp file entry | getut(3) |
| getutline | Access utmp file entry | getut(3) |
| getw | Get character/word from stream | getc(3s) |
| getwd | Get current working directory | getwd(3) |
| gmtime | Convert date and time | ctime(3) |
| gmtime | Convert date and time (SYSTEM V) | ctime(3v) |
| gsignal | Software signals | ssignal(3) |
| hcreate | Manage hash search tables | hsearch(3) |
| hdestroy | Manage hash search tables | hsearch(3) |
| hsearch | Manage hash search tables | hsearch(3) |
| index | String operation | string(3) |
| isalpha | Character classification | ctype(3) |
| isalnum | Character classification | ctype(3) |
| isascii | Character classification | ctype(3) |
| isatty | Find terminal port name | ttyname(3) |
| iscntrl | Character classification | ctype(3) |
| isdigit | Character classification | ctype(3) |
| isgraph | Character classification | ctype(3) |
| islower | Character classification | ctype(3) |
| isprint | Character classification | ctype(3) |
| ispunct | Character classification | ctype(3) |
| isspace | Character classification | ctype(3) |
| isupper | Character classification | ctype(3) |
| isxdigit | Character classification | ctype(3) |
| jrand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| l3tol | Convert 3-byte and long integers | l3tol(3) |
| l64a | Convert long integer and base-64 ASCII string | a64l(3) |
| lcong48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| ldexp | Split into mantissa and exponent | frexp(3) |
| lfind | Linear search and update | lsearch(3) |
| localtime | Convert date and time | ctime(3) |
| localtime | Convert date and time (SYSTEM V) | ctime(3v) |
| lockf | Files record locking | lockf(3) |
| longjmp | Non-local goto | setjmp(3) |
| lrand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| lsearch | Linear search and update | lsearch(3) |
| ltol3 | Convert 3-byte and long integers | l3tol(3) |
| malloc | Main memory allocator | malloc(3) |
| memccpy | Memory operations | memory(3) |
| memchr | Memory operations | memory(3) |
| memcmp | Memory operations | memory(3) |
| memcpy | Memory operations | memory(3) |
| memset | Memory operations | memory(3) |
| mkdir | Make directory file | mkdir(3) |
| mktemp | Make unique file name | mktemp(3) |
| modf | Split into mantissa and exponent | frexp(3) |
| monitor | Prepare execution profile | monitor(3) |
| mrand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| nlist | Get name list entry | nlist(3) |
| nrand48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| opendir | Directory operation | directory(3) |
| openlog | Control system log | syslog(3) |
| pclose | Initiate I/O to/from process | popen(3s) |
| perror | System error messages | perror(3) |
| popen | Initiate I/O to/from process | popen(3s) |
| printf | Formatted output conversion | printf(3s) |
| psignal | System signal messages | psignal(3) |
| putc | Put character or word on stream | putc(3s) |
| putchar | Put character or word on stream | putc(3s) |
| putenv | Change/add value to environment | putenv(3) |
| putpwent | Write password file entry | putpwent(3) |
| puts | Put string on stream | puts(3s) |
| pututline | Access utmp file entry | getut(3) |
| putw | Put character or word on stream | putc(3s) |
| qsort | Quick sort | qsort(3) |
| rand | Random number generator | rand(3) |
| re_comp | Regular expression handler | regex(3) |
| re_exec | Regular expression handler | regex(3) |
| readdir | Directory operation | directory(3) |
| realloc | Main memory allocator | malloc(3) |
| rename | Change file name | rename(3) |
| rewind | Reposition stream | fseek(3s) |
| rewinddir | Directory operation | directory(3) |
| rindex | String operation | string(3) |
| rmdir | Remove directory | rmdir(3) |
| scanf | Formatted input conversion | scanf(3s) |
| seed48 | Uniformly distributed pseudo-random numbers | drand48(3) |
| seekdir | Directory operation | directory(3) |
| setbuf | Assign buffering to a stream | setbuf(3s) |
| setegid | Set effective group ID | seteuid(3) |
| seteuid | Set effective user ID | seteuid(3) |
| setkey | Set encryption key | crypt(3) |
| setrgid | Set real group ID | seteuid(3) |
| setruid | Set real user ID | seteuid(3) |
| setfsent | Get file system descriptor | getfsent(3) |
| setgrent | Get group file entry | getgrent(3) |
| setjmp | Non-local goto | setjmp(3) |
| setpwent | Get password file entry | getpwent(3) |
| setutent | Access utmp file entry | getut(3) |
| setvbuf | Assign buffering to stream | setbuf(3s) |
| sighold | Manage signals (job control) | sigset(3j) |
| sigignore | Manage signals (job control) | sigset(3j) |
| signal | Manage signals (job control) | sigset(3j) |
| sigpause | Manage signals (job control) | sigset(3j) |
| sigrelse | Manage signals (job control) | sigset(3j) |
| sigset | Manage signals (job control) | sigset(3j) |
| sleep | Suspend execution for interval | sleep(3) |
| sprintf | Formatted output conversion | printf(3s) |
| srand | Random number generator | rand(3) |
| srand48 | Uniformly distributed pseudorandom numbers | drand48(3) |
| sscanf | Formatted input conversion | scanf(3s) |
| ssignal | Software signals | ssignal(3) |
| stdio | Standard buffered I/O package | stdio(3s) |
| strcat | String operation | string(3) |
| strchr | String operation | string(3) |
| strcmp | String comparison intrinsic functions | string(3) |
| strcpy | String operation | string(3) |
| strcspn | String operation | string(3) |
| strlen | String operation | string(3) |
| strncat | String operation | string(3) |
| strncmp | String operation | string(3) |
| strncpy | String operation | string(3) |
| strpbrk | String operation | string(3) |
| strrchr | String operation | string(3) |
| strspn | String operation | string(3) |
| strtod | Convert string to double-precision number | strtod(3) |
| strtok | String operation | string(3) |
| strtol | Convert string to integer | strtol(3) |
| swab | Swap bytes | swab(3) |
| syslog | Control system log | syslog(3) |
| system | Issue shell command | system(3s) |
| _toupper | Translate character | conv(3) |
| _tolower | Translate character | conv(3) |
| tdelete | Manage binary search trees | tsearch(3) |
| telldir | Directory operation | directory(3) |
| tfind | Manage binary search trees | tsearch(3) |
| tgetent | Terminal independent operation | termlib(3) |
| tempnam | Create temporary file name | tmpnam(3s) |
| tgetflag | Terminal independent operation | termlib(3) |
| tgetnum | Terminal independent operation | termlib(3) |
| tgetstr | Terminal independent operation | termlib(3) |
| tgoto | Terminal independent operation | termlib(3) |
| timezone | Convert date and time to ASCII | ctime(3) |
| tmpfile | Create temporary file | tmpfile(3s) |
| tmpnam | Create name for temporary file | tmpnam(3s) |
| toascii | Translate characters | conv(3) |
| tolower | Translate characters | conv(3) |
| toupper | Translate characters | conv(3) |
| tputs | Terminal independent operation routines | termlib(3) |
| tsearch | Manage binary search trees | tsearch(3) |
| ttyname | Find terminal name | ttyname(3) |
| ttyslot | Find terminal name | ttyslot(3) |
| ttyslot | Find terminal name (SYSTEM V) | ttyslot(3v) |
| twalk | Manage binary search trees | tsearch(3) |
| tzset | Convert date and time to ASCII | ctime(3v) |
| undial | Release semaphore | dial(3) |
| ungetc | Push character back into input stream | ungetc(3s) |
| utmpname | Access utmp file entry | getut(3) |
| vfprintf | Print formatted output of varargs list | vprintf(3s) |
| vprintf | Print formatted output of varargs list | vprintf(3s) |
| vsprintf | Print formatted output of varargs list | vprintf(3s) |
DEFINITIONS
A character is any bit pattern able to fit into a byte on the machine. The null character is a character with value 0, represented in the C language as ’\0’. A character array is a sequence of characters. A null-terminated character array is a sequence of characters, the last of which is the null character. A string is a designation for a null-terminated character array. The null string is a character array containing only the null character. A NULL pointer is the value that is obtained by casting 0 into a pointer. The C language guarantees that this value will not match that of any legitimate pointer, so many functions that return pointers return it to indicate an error. NULL is defined as 0 in <stdio.h>; the user can include an appropriate definition if not using <stdio.h>.
Many groups of FORTRAN intrinsic functions have generic function names that do not require explicit or implicit type declaration. The type of the function will be determined by the type of its argument(s). For example, the generic function max will return an integer value if given integer arguments (max0), a real value if given real arguments (amax1), or a double-precision value if given double-precision arguments (dmax1).
WARNING
Many of the functions in the libraries call and/or refer to other functions and external variables described in this section and in section 2 (System Calls). If a program inadvertently defines a function or external variable with the same name, the presumed library version of the function or external variable may not be loaded. The lint(1) program checker reports name conflicts of this kind as “multiple declarations” of the names in question. Definitions for sections 2, 3, and 3s are checked automatically. Other definitions can be included by using the −l option (for example, −lm includes definitions for the Math Library, section 3m). Use of lint is highly recommended.
FILES
/lib/libc.a
/lib/libcV.aSYSTEM V compatibility library
SEE ALSO
cc(1), ld(1), nm(1), intro(2), intro(3f), intro(3j), intro(3m), intro(3n), intro(3x), stdio(3s)
ASSEMBLER
In assembly language these functions may be accessed by simulating the C calling sequence. For example, ecvt(3) might be called this way:
setd
mov$sign,−(sp)
mov$decpt,−(sp)
movndigit,−(sp)
movfvalue,−(sp)
jsrpc,_ecvt
add$14.,sp