C Functions


This is a summary of the useful functions I have come acros!cps. I have grouped the functions by library. If you want an alphabetical list, please use the master index. Please refer to a manual for a complete list of ANSI functions.
Please use this field to search for specific entries.

ANSI standard libraries.

The ANSI library is declared in the following header files.

assert.h ctype.h errno.h float.h limits.h
locale.h math.h setjmp.h signal.h stdarg.h
stddef.h stdio.h stdlib.h string.h time.h

assert.h

assert

ctype.h

isalnum Checks whether a character is alphanumeric (A-Z, a-z, 0-9)
isalpha
iscntrl Checks whether a character is a control character or delete ( decimal 0-31 and 127)
isdigit Checks whether a character is a digit (0-9)
isgraph Checks whether a character is a printable character, excluding the space (decimal 32)
islower Checks whether a character is a lower case letter (a-z).
isprint Checks whether a character is printable (decimal 32-126).
ispunct Checks whether a character is punctuation (decimal 32-47, 58-63, 91-96, 123-126)
isspace Checks whether a character is white space - space, CR HT VT NL, FF.
isupper Checks whether a character is an upper case letter (A-Z).
isxdigit Checks whether a character is hex digit (0-9, A-F, a-f).
toupper Converts a lowercase character to uppercase.
	int toupper(int c)
tolower Convert an uppercase character to lowercase.
	int tolower(int c)

errno.h

errno

float.h

No functions are declared in stddef.h.

limits.h

No functions are declared in stddef.h.

locale.h

setlocale

math.h

acos asin atan atan2 cos sin tan cosh sinh tanh exp frexp ldexp log log10 modf pow sqrt ceil fabs floor fmod

Note

For some reason abs is in stdlib.h

setjmp.h

setjmp longjmp

signal.h

signal
raise

stdarg.h

va_start
va_arg
va_end

stddef.h

No functions are declared in stddef.h.

stdio.h

This header defines all the ANSI I/O functions that allow you to read and write to files and devices.
Low level (non ANSI) functions are also available.

Entries are not in order - yet.

rename Rename a file. MAN PAGE.
remove remove a file. MAN PAGE.
tmpfile MAN PAGE.
tmpnam MAN PAGE.
fflush MAN PAGE.
freopen MAN PAGE.
setbuf MAN PAGE.
setvbuf MAN PAGE.
fscanf MAN PAGE.
sscanf Extract fields from a string.
vfprintf MAN PAGE.
vprintf MAN PAGE.
vsprintf MAN PAGE.
fclose Close a file.
fopen Open a file
fgetc Read a character from a file.
feof Check for EOF while reading a file.
fgets Read a record from a file (safer than fgetc).
fprintf O/P a line of data to a file.
fputc Put a charater into a file.
fputs Put a string into a file.
printf O/P data to the screen or a file.
sprintf O/P data in tha same way as 'printf' but put it into a string.
getc Get a character from an input stream.
getchar Get a character from the keyboard (STDIN).
gets Get string (from keyboard).
putchar O/P a character to STDOUT.
puts O/P data to the screen or a file.
scanf
ungetc
fread
fwrite
fgetpos
fseek
fsetpos
ftell
rewind
clearerr
fseek

stdlib.h

abort
abs
atexit
atof
atoi Accepts +-0123456789 leading blanks and converts to integer.
atol
bsearch Binary chop.
calloc
div
exit
getenv Get an environmental variable.
free memory allocated with malloc.
labs
ldiv
malloc dynamically allocate memory.
mblen
mbstowcs
mbtowc
qsort Sort an array.
rand Generate a random number.
realloc
strtod
strtol String to long integer conversion. Takes data in various number bases.
strtoul
srand Seed a random number.
system Issue a command to the operating system
wctomb
wcstombs

string.h

memchr
memcmp
memcpy
memmove
memset
strcat Concatinate two strings.
strchr Search for a character in a string.
strcmp Compare strings.
strcoll
strcpy Copy strings.
strcspn
strerror
strlen
strncat
strncmp
strncpy Copy part of a string.
strpbrk
strrchr Search for a character in a string.
strspn
strstr Search a string for a substring.
strtok The books say this function splits a string into tokens. I think its function is best described as parsing a string.
strxfrm

time.h

asctime
clock
ctime
difftime
gmtime
localtime
mktime
strftime
time
Example program using some of the time functions.

conio.h

Dos Specific functions in conio.h Not very portable as conio.h is NOT in the ANSI standard library and does not appear on the Sun or Linux machines.

clrscr Clear screen
getch Get a character from the keyboard.
getche Get a character from the keyboard.


Non ANSI Standard Unix Functions.

These functions are not in the ANSI standard libraries but are handy all the same.


dirent.h

opendir Open a directory.
closedir Close a directory.
readdir Read a directory entry.
rewinddir Return to the beginning of a directory.
scandir Scan a directory for a matching entry.
seekdir Move to an offset in a directory.
telldir Return the location within a directory.

unistd.h

My documentation for this libray is incomplete.
chdir Change the current working directory.
close Close a file (see low level functions).
getopt, parse the command line.
gethostname Name of the host (see uname).

Ungrouped functions

endpwent
fgetpwent
getpw
getpwent
getpwnam Get a record by keying on the user name.
getpwuid Get a record by keying on the UID (numeric).
getuidx Get the User ID of a process (RS/6000 only).
index Search for a character in a string (Use strchr to conform to the ANSI standard).
open Open a file (see low level functions).
putpwent
pclose Close a pipe.
popen Open a Unix pipe.
putenv Change or create an environmental variable.
read Read a file (see low level functions).
setenv Change or create an environmental variable.
setpwent
setuid seteuid setruid Set the User ID of the process.
setgid setegid setrgid Set the Group ID of the process.
getuid geteuid getruid Get the User ID of the process.
setreuid Set the ID of the process calling process.
setuidx Set the User ID of the process (RS/6000 only).
stat Get status information on files (modification time, file size etc).
uname Get information about the machine we are running on.
unsetenv Remove an environmental variable.
write Write a file (see low level functions).
sizeof Return the storage allocation for a data type. This is actually an operator! I have put it in here as it looks like a function and so you will probably look for it here....


User written functions
(and a few lifted from books)


reverse. Reverse characters in a string.
clrscr. Clear the screen using VT escape sequence.
convesc. Insert escape codes into a text string.
basename. Strip directory information from a Unix file name.

Top Master Index Keywords Functions


Martin Leslie 18-Feb-96