C Standard Library Functions

FreeBASIC

C Standard Library Functions
 
This is a list of function prototypes in the standard C library in alphabetical order and a list of prototypes grouped by functionality.

Alphabetical List
Buffer Manipulation
Character Classification and Conversion
Data Conversion
Directory Manipulation
File Manipulation
Stream I/O
Low level I/O
Mathematics
Memory Allocation
Process Control
Searching and Sorting
String Manipulation
Time

Description

The Comments column contains a very brief description of the use of the function. The list is not complete, however it provides information on the major functions in the C Runtime Library. It should, at the very least, indicate what functions are available in the standard C library allow you to do more investigation on your own. Some of the C library functions documented elsewhere may not be available in FreeBASIC. Check the appropriate include file for more information.

Note: The following prototypes are not the official FreeBASIC prototypes (see the include files), however, they will give you enough information to properly use the functions.

The Include File column contains the name of the file which you must include, using the #include directive at the beginning of your program. If you don't include the appropriate include file, the program either will not compile, or it will compile apparently correctly but give incorrect results when run. All of the C Runtime headers are located in the crt directory; for example, if the specified header is math.bi, use #include "crt/math.bi" or #include "crt\math.bi", our just #include "crt.bi" including all the others.

The Prototype column contains the following information:
    • The name of the function;
    • The parameters required for the function in parenthesis, together with the data-type of the parameters;
    • The data-type of the value returned by the function.

For example atoi(a as zstring ptr) as integer means that the function atoi returns a value of type integer and requires a character zstring ptr as its argument.

Note: In order to make calling the C runtime functions very easy, any string type argument may be directly passed to a procedure referring to a parameter declared as 'zstring ptr'. The compiler performs itself an automatic conversion (without warning message) between string and 'zstring ptr'.

Alphabetical List


NamePrototype (with parameters)Include FileComments
abs_abs_(n as integer) as integerstdlib.biReturns the absolute value (i.e. positive value)
acos_acos_(a as double) as doublemath.biReturns the inverse cosine (angle in radians)
asin_asin_(a as double) as doublemath.biReturns the inverse sine (angle in radians)
atan_atan_(a as double) as doublemath.biReturns the inverse tan (angle in radians)
atan2_atan2_(y as double, x as double) as doublemath.biReturns the inverse tan (pass the opposite as y and the adjacent as x)
atoiatoi(s as zstring ptr) as integerstdlib.biConverts a character zstring of digits to a number of type integer.
atofatof(s as zstring ptr) as doublestdlib.biConverts a character zstring of digits to a number of type double.
calloccalloc(NumElts as integer, EltSiz as integer) as any ptrstdlib.biAllocates memory. Returns a pointer to a buffer for an array having NumElts elements, each of size EltSiz bytes.
ceilceil(d as double) as doublemath.biReturns the nearest whole number above the value passed.
clearerrclearerr(s as FILE ptr)stdio.biClears the error indicators on a file stream (read or write).
cos_cos_(ar as double) as doublemath.biReturns the cosine of an angle measured in radians.
coshcosh(x as double) as doublemath.biReturns the hyperbolic cosine of an angle measured in radians.
divdiv(num as integer, denom as integer) as div_tstdlib.biReturns the quotient and remainder of a division as a structure of type div_t.
ecvtecvt(x as double) as zstring ptrmath.biConverts a number to a zstring.
exit_exit_(status as integer)stdlib.biExits a program. It will flush file buffers and closes all opened files, and run any functions called by atexit().
exp_exp_(a as double) as doublemath.biReturns the value of e raised to the power of the argument (Inverse to natural logarithm).
fabsfabs(d as double) as doublemath.biReturns the absolute value (i.e. positive value) of type double.
fclosefclose(s as FILE ptr) as FILE ptrstdio.biCloses a file. Returns 0 if successful otherwise EOF.
feoffeof(s as FILE ptr) as integerstdio.biReturns value of end-of-file indicator . (0 if not eof). Indicator will clear itself but can be reset by clearerr().
ferrorferror(s as FILE ptr) as integerstdio.biReturns error indicator for a stream (0 if no error). Error indicator is reset by clearerr() or rewind().
fflushfflush(s as FILE ptr) as integerstdio.biFlushes (i.e. deletes) a stream (use stdin to flush the stream from the keyboard). Returns 0 if successful.
fgetcfgetc(s as FILE ptr) as integerstdio.biSingle character input (in ASCII) from passed stream (stdin for keyboard).
fgetposfgetpos(s as FILE ptr, c as fpos_t ptr) as integerstdio.biSaves the position of the file pointer on stream s at the location pointed to by c.
fgetsfgets(b as zstring ptr, n as integer, s as FILE ptr) as zstring ptrstdio.biFrom the stream s reads up to n-1 characters to buffer b.
floorfloor(d as double) as doublemath.biReturns the nearest whole number below the value passed.
fmodfmod(x as double, y as double) as doublemath.biCalculates the remainder of x divided by y.
fopenfopen(file as zstring ptr, mode as zstring ptr) as FILE ptrstdio.biOpens a file. Pass the DOS name of the file and a code to indicate whether for reading, writing, or appending. Codes are r for read, w for write, + for read and write, a for append and b to indicate binary.
fprintffprintf(s as FILE ptr, fmt as zstring ptr, ...) as integerstdio.biPrints on stream s as many items as there are single % signs in fmt that have matching arguments in the list.
fputcfputc(c as integer, s as FILE ptr) as integerstdio.biOutputs the single character c to the stream s.
fputsfputs(b as zstring ptr, s as FILE ptr) as integerstdio.biSends the character stream in b to stream s, returns 0 if the operation fails.
freadfread(buf as any ptr, b as size_t, c as size_t, s as FILE ptr) as integerstdio.biReads the number c items of data of size b bytes from file s to the buffer buf. Returns the number of data items actually read.
freefree(p as any ptr)stdlib.biFrees the memory allocation for a pointer p to enable this memory to be used.
freopenfreopen(file as zstring ptr, mode as zstring ptr, s as FILE ptr) as FILE ptrstdio.biOpens a file for redirecting a stream. e.g. freopen("myfile", "w", stdout) will redirect the standard output to the opened "myfile".
frexpfrexp(x as double, p as integer ptr) as doublemath.biCalculates a value m so that x equals m times 2 to some power. p is a pointer to m.
fscanffscanf(s as FILE ptr, fmt as zstring ptr, ...) as integerstdio.biReads from stream s as many items as there are % signs in fmt with corresponding listed pointers.
fseekfseek(s as FILE ptr, offset as integer, origin as integer) as integerstdio.biLocates a file pointer. With origin 0, 1 or 2 for the beginning, offset bytes into and at the end of the stream.
fsetposfsetpos(s as FILE ptr, p as fpos_t ptr) as integerstdio.biSets the file pointer for the stream s to the value pointed to by p.
ftellftell(s as FILE ptr) as longstdio.biLocates the position of the file pointer for the stream s.
fwritefwrite(buf as any ptr, b as integer, c as integer, s as FILE ptr) as integerstdio.biWrites the number c items of data of size b bytes from the buffer buf to the file s. Returns the number of data items actually written.
getcgetc(s as FILE ptr) as integerstdio.biMacro for single character input (in ASCII) from passed stream. (stdin for keyboard)
getchargetchar() as integerstdio.biSingle character input from the standard input
getsgets(b as zstring ptr) as zstring ptrstdio.biReads a stream of characters from the standard input until it meets \n or EOF.
hypothypot(x as double, y as double) as doublemath.biCalculates the hypotenuse from the sides x and y.
isalnumisalnum(c as integer) as integerctype.biReturns a non zero value if character c is alphabetic or a digit.
isalphaisalpha(c as integer) as integerctype.biReturns a non zero value if character c is alphabetic.
iscntrliscntrl(c as integer) as integerctype.biReturns a non zero value if character c is a control character.
isdigitisdigit(c as integer) as integerctype.biReturns a non zero value if character c is a digit.
isgraphisgraph(c as integer) as integerctype.biReturns a non zero value if character c is alphabetic.
islowerislower(c as integer) as integerctype.biReturns a non-zero value if character c is a lower case character.
isprintisprint(c as integer) as integerctype.biReturns a non zero value if character c is printable.
ispunctispunct(c as integer) as integerctype.biReturns a non zero value if character c is a punctuation character.
isspaceisspace(c as integer) as integerctype.biReturns a non zero value if character c denotes a space.
isupperisupper(c as integer) as integerctype.biReturns a non-zero value if character c is an upper case character.
isxdigitisxdigit(c as integer) as integerctype.biReturns a non-zero value if character c is a hex digit (0 to F or f).
ldexpldexp(x as double, n as integer) as doublemath.biReturns the product of x and 2 to the power n.
ldivldiv(num as long, denom as long) as ldiv_tstdlib.biReturns the quotient and remainder of a division as a structure of type ldiv_t.
log_log_(a as double) as doublemath.biReturns the natural logarithm of the argument.
log10log10(a as double) as doublemath.biReturns the logarithm to the base 10 of the argument.
mallocmalloc(bytes as integer) as any ptrstdlib.biAllocates memory. Returns a pointer to a buffer comprising storage for the specified size.
modfmodf(d as double, p as double ptr) as doublemath.biReturns the fractional part of a floating point number d. p points to the integral part expressed as a float.
perrorperror(mess as zstring ptr)stdio.biPrints on the stream stderr a message passed as the argument.
powpow(x as double, y as double) as doublemath.biReturns x to the power y.
pow10pow10(x as double) as doublemath.biReturns 10 to the power x (inverse function to log10()).
printfprintf(fmt as zstring ptr, ...) as integerstdio.biPrints on standard output as many items as there are single % signs in fmt with matching arguments in the list.
putcputc(c as integer, s as FILE ptr) as integerstdio.biMacro to output the single character c to the stream s.
putcharputchar(c as integer) as integerstdio.biMacro to output the single character c to the standard output.
putsputs(b as zstring ptr) as integerstdio.biSends the character stream in b to the standard output, returns 0 if operation fails.
randrand() as integerstdlib.biReturns a pseudo random number. A seed is required. The seed is set with srand.
reallocrealloc(p as any ptr, newsize as size_t) as any ptrstdlib.biAllocates memory. Returns a pointer to a buffer for a change in size of object pointed to by p.
rewindrewind(s as FILE ptr)stdio.biClears the error indicators on a file stream (read or write). Necessary before reading an amended file.
scanfscanf(fmt as zstring ptr, ...) as integerstdio.biReads from standard input as many items as there are % signs in fmt with corresponding listed pointers.
sin_sin_(ar as double) as doublemath.biReturns the sine of an angle measured in radians.
sinhsinh(x as double) as doublemath.biReturns the hyperbolic sine of an angle measured in radians.
sprintfsprintf(p as zstring ptr, fmt as zstring ptr, ...) as integerstdio.biPrints on zstring p as many items as there are single % signs in fmt that have matching arguments in the list.
sqrtsqrt(a as double) as doublemath.biReturns the square root of the value passed. Domain error if value is negative.
srandsrand(seed as uinteger)stdlib.biSets the seed for a random number. A possible seed is the current time.
sscanfsscanf(b as zstring ptr, fmt as zstring ptr, ...) as integerstdio.biReads from buffer b as many items as there are % signs in fmt with corresponding listed pointers.
strcatstrcat(s1 as zstring ptr, s2 as zstring ptr) as zstring ptrstring.biConcatenates (appends) zstring s2 to s1.
strchrstrchr(s as zstring ptr, c as integer) as zstring ptrstring.biReturns a pointer to the first occurrence of c in s or NULL if it fails to find one.
strcmpstrcmp(s1 as zstring ptr, s2 as zstring ptr) as integerstring.biCompares zstring s2 to s1. Returns 0 or signed difference in ASCII values of first non matching character.
strcpystrcpy(s1 as zstring ptr, s2 as zstring ptr) as zstring ptrstring.biCopies s2 into s1.
strcspnstrcspn(s1 as zstring ptr, s2 as zstring ptr) as integerstring.biReturns the number of characters in s1 encountered before meeting any of the characters in s2.
strerrorstrerror(n as integer) as zstring ptrstring.biReturns a pointer to a system error message corresponding to the passed error number.
strlenstrlen(s as zstring ptr) as integerstring.biReturns the number of bytes in the null terminated zstring pointed to by s (does not count null).
strncatstrncat(s1 as zstring ptr, s2 as zstring ptr, n as integer) as zstring ptrstring.biConcatenates (appends) n bytes from zstring s2 to s1.
strncmpstrncmp(s1 as zstring ptr, s2 as any ptr, n as integer) as integerstring.biCompares n bytes of zstring s2 to the same of s1. Returns 0 or signed difference in ASCII values of first non matching character.
strncpystrncpy(s1 as zstring ptr, s2 as zstring ptr, n as integer) as zstring ptrstring.biCopies n bytes from s2 into s1.
strpbrkstrpbrk(s1 as zstring ptr, s2 as zstring ptr) as zstring ptrstring.biReturns a pointer to the first character encountered in s1 that is also in s2.
strrchrstrrchr(s as zstring ptr, c as integer) as zstring ptrstring.biReturns a pointer to the last occurrence of c in s or NULL if it fails to find one.
strspnstrspn(s1 as zstring ptr, s2 as zstring ptr) as integerstring.biReturns the number of characters in s1 encountered before meeting a character which is not in s2.
strstrstrstr(s1 as zstring ptr, s2 as zstring ptr) as zstring ptrstring.biFinds the location of the zstring s2 in s1 and returns a pointer to its leading character.
strtodstrtod(s as zstring ptr, p as zstring ptr) as doublestdlib.biConverts a zstring to double, provided the zstring is written in the form of a number.
strtokstrtok(s1 as zstring ptr, s2 as zstring ptr) as zstring ptrstring.biReturns pointers to successive tokens utilizing the zstring s1. Tokens regarded as separators are listed in s2.
systemsystem(command as zstring ptr) as integerstdlib.biExecutes, from within a program, a command addressed to the operating system written as a zstring (e.g. DIR on Windows and DOS and LS on Linux).
tan_tan_(ar as double) as doublemath.biReturns the tangent of an angle measured in radians.
tanhtanh(x as double) as doublemath.biReturns the hyperbolic tangent of an angle measured in radians.
tolowertolower(c as integer) as integerctype.biConverts a character from upper case to lower case (uses ASCII code).
touppertoupper(c as integer) as integerctype.biConverts a character from lower case to upper case (uses ASCII code).
ungetcungetc(c as integer, s as FILE ptr) as integerstdio.biPushes a character c back into the stream s, returns EOF if unsuccessful. Do not push more than one character.


Buffer Manipulation


#include "crt/string.bi"

Prototype (with parameters)Comments
memchr(s as any ptr, c as integer, n as size_t) as any ptrSearch for a character in a buffer.
memcmp(s1 as any ptr, s2 as any ptr, n as size_t) as integerCompare two buffers.
memcpy(dest as any ptr, src as any ptr, n as size_t) as any ptrCopy one buffer into another .
memmove(dest as any ptr, src as any ptr, n as size_t) as any ptrMove a number of bytes from one buffer lo another.
memset(s as any ptr, c as integer, n as size_t) as any ptrSet all bytes of a buffer to a given character.


Character Classification and Conversion


#include "crt/ctype.bi"

Prototype (with parameters)Comments
isalnum(c as integer) as integerTrue if c is alphanumeric.
isalpha(c as integer) as integerTrue if c is a letter.
isascii(c as integer) as integerTrue if c is ASCII .
iscntrl(c as integer) as integerTrue if c is a control character.
isdigit(c as integer) as integerTrue if c is a decimal digit.
isgraph(c as integer) as integerTrue if c is a graphical character.
islower(c as integer) as integerTrue if c is a lowercase letter.
isprint(c as integer) as integerTrue if c is a printable character.
ispunct(c as integer) as integerTrue if c is a punctuation character.
isspace(c as integer) as integerTrue if c is a space character.
isupper(c as integer) as integerTrue if c is an uppercase letter.
isxdigit(c as integer) as integerTrue if c is a hexadecimal digit.
toascii(c as integer) as integerConvert c to ASCII .
tolower(c as integer) as integerConvert c to lowercase.
toupper(c as integer) as integerConvert c to uppercase.


Data Conversion


#include "crt/stdlib.bi"

Prototype (with parameters)Comments
atof(string1 as zstring ptr) as doubleConvert zstring to floating point value.
atoi(string1 as zstring ptr) as integerConvert zstring to an integer value.
atol(string1 as zstring ptr) as integerConvert zstring to a long integer value.
itoa(value as integer, zstring as zstring ptr, radix as integer) as zstring ptrConvert an integer value to a zstring using given radix.
ltoa(value as long, zstring as zstring ptr, radix as integer) as zstring ptrConvert long integer to zstring in a given radix.
strtod(string1 as zstring ptr, endptr as zstring ptr) as doubleConvert zstring to a floating point value.
strtol(string1 as zstring ptr, endptr as zstring ptr, radix as integer) as longConvert zstring to a long integer using a given radix.
strtoul(string1 as zstring ptr, endptr as zstring ptr, radix as integer) as ulongConvert zstring to unsigned long.


Directory Manipulation


#include "crt/io.bi"

Prototype (with parameters)Comments
_chdir(path as zstring ptr) as integerChange current directory to given path.
_getcwd(path as zstring ptr, numchars as integer) as zstring ptrReturns name of current working directory.
_mkdir(path as zstring ptr) as integerCreate a directory using given path name.
_rmdir(path as zstring ptr) as integerDelete a specified directory.


File Manipulation


#include "crt/sys/stat.bi"
#include "crt/io.bi"

Prototype (with parameters)Comments
chmod(path as zstring ptr, pmode as integer) as integerChange permission settings of a file.
fstat(handle as integer, buffer as type stat ptr) as integerGet file status information.
remove(path as zstring ptr) as integerDelete a named file.
rename_(oldname as zstring ptr, newname as zstring ptr) as integerrename a file.
stat(path as zstring ptr, buffer as type stat ptr) as integerGet file status information of named file.
umask(pmode as uinteger) as uintegerSet file permission mask.


Stream I/O


#include "crt/stdio.bi"

Prototype (with parameters)Comments
clearerr(file_pointer as FILE ptr)Clear error indicator of stream,
fclose(file_pointer as FILE ptr) as integerClose a file,
feof(file_pointer as FILE ptr) as integerCheck if end of file occurred on a stream.
ferror(file_pointer as FILE ptr) as integerCheck if any error occurred during file I/0.
fflush(file_pointer as FILE ptr) as integerWrite out (flush) buffer to file.
fgetc(file_pointer as FILE ptr) as integerGet a character from a stream.
fgetpos(file_pointer as FILE ptr, fpos_t current_pos) as integerGet the current position in a stream.
fgets(string1 as zstring ptr, maxchar as integer, file_pointer as FILE ptr) as zstring ptrRead a zstring from a file.
fopen(filename as zstring ptr, access_mode as zstring ptr) as FILE ptrOpen a file for buffered I/0.
fprintf(file_pointer as FILE ptr, format_string as zstring ptr, args) as integerWrite formatted output to a file,
fputc(c as integer, file_pointer as FILE ptr) as integerWrite a character to a stream.
fputchar(c as integer) as integerWrite a character to stdout.
fputs(string1 as zstring ptr, file_pointer as FILE ptr) as integerWrite a zstring to a stream.
fread(buffer as zstring ptr, size as size_t count as size_t, file_pointer as FILE ptr) as size_tRead unformatted data from a stream into a buffer.
freopen(filename as zstring ptr, access as zstring ptr mode, file_pointer as FILE ptr) as FILE ptrReassign a file pointer to a different file.
fscanf(file_pointer as FILE ptr, format as zstring ptr zstring, args) as integerRead formatted input from a stream.
fseek(file_pointer as FILE ptr, offset as long, origin as integer) as integerSet current position in file to a new location.
fsetpos(file_pointer as FILE ptr, current_pos as fpos_t) as integerSet current position in file to a new location.
ftell(file_pointer as FILE ptr) as longGet current location in file.
fwrite(buffer as zstring ptr, size as size_t, count as size_t file_pointer as FILE ptr) as size_tWrite unformatted data from a buffer to a stream.
getc(file_pointer as FILE ptr) as integerRead a character from a stream.
getchar() as integerRead a character from stdin.
gets(buffer as zstring ptr) as zstring ptrRead a line from stdin into a buffer.
printf(format as zstring ptr _string, args) as integerWrite formatted output to stdout.
putc(c as integer, file_pointer as FILE ptr) as integerWrite a character to a stream.
putchar(c as integer) as integerWrite a character to stdout.
puts(string1 as zstring ptr) as integerWrite a zstring to stdout.
rewind(file_pointer as FILE ptr)Rewind a file.
scanf(format_string as zstring ptr, args) as integerRead formatted input from stdin.
setbuf(file_pointer as FILE ptr, buffer as zstring ptr)Set up a new buffer for the stream.
setvbuf(file_pointer as FILE ptr, buffer as zstring ptr, buf_type as integer, buf as size_t size) as integerSet up new buffer and control the level of buffering on a stream.
sprintf(string1 as zstring ptr, format_string as zstring ptr, args) as integerWrite formatted output to a zstring.
sscanf(buffer as zstring ptr, format_string as zstring ptr, args) as integerRead formatted input from a zstring.
tmpfile() as FILE ptrOpen a temporary file.
tmpnam(file_name as zstring ptr) as zstring ptrGet temporary file name.
ungetc(c as integer, file_pointer as FILE ptr) as integerPush back character into stream' s buffer


Low level I/O


#include "crt/io.bi"

So far Win32 only, connects to MSVCRT.DLL (headers missing for other platforms)

Prototype (with parameters)Comments
_close(handle as integer) as integerClose a file opened for unbuffered I/O.
_creat(filename as zstring ptr, pmode as integer) as integerCreate a new file with specified permission setting.
_eof(handle as integer) as integerCheck for end of file.
_lseek(handle as integer, offset as long, origin as integer) as longGo to a specific position in a file.
_open(filename as zstring ptr, oflag as integer, pmode as uinteger) as integerOpen a file for low-level I/O.
_read(handle as integer, buffer as zstring ptr, length as uinteger) as integerRead binary data from a file into a buffer.
_write(handle as integer, buffer as zstring ptr, count as uinteger) as integerWrite binary data from a buffer to a file.


Mathematics


#include "crt/math.bi"

Prototype (with parameters)Comments
abs_(n as integer) as integerGet absolute value of an integer.
acos_(x as double) as doubleCompute arc cosine of x.
asin_(x as double) as doubleCompute arc sine of x.
atan_(x as double) as doubleCompute arc tangent of x.
atan2_(y as double, x as double) as doubleCompute arc tangent of y/x.
ceil(x as double) as doubleGet smallest integral value that exceeds x.
cos_(x as double) as doubleCompute cosine of angle in radians.
cosh(x as double) as doubleCompute the hyperbolic cosine of x.
div(number as integer, denom as integer) as div_tDivide one integer by another.
exp_(x as double) as doubleCompute exponential of x.
fabs(x as double) as doubleCompute absolute value of x.
floor(x as double) as doubleGet largest integral value less than x.
fmod(x as double, y as double) as doubleDivide x by y with integral quotient and return remainder.
frexp(x as double, expptr as integer ptr) as doubleBreaks down x into mantissa and exponent of no.
labs(n as long) as longFind absolute value of long integer n.
ldexp(x as double, exp as integer) as doubleReconstructs x out of mantissa and exponent of two.
ldiv(number as long, denom as long) as ldiv_tDivide one long integer by another.
log_(x as double) as doubleCompute log(x).
log10(x as double) as doubleCompute log to the base 10 of x.
modf(x as double, intptr as double ptr) as doubleBreaks x into fractional and integer parts.
pow(x as double, y as double) as doubleCompute x raised to the power y.
rand() as integerGet a random integer between 0 and 32767.
random(max_num as integer) as integerGet a random integer between 0 and max_num.
randomize()Set a random seed for the random number generator.
sin_(x as double) as doubleCompute sine of angle in radians.
sinh(x as double) as doubleCompute the hyperbolic sine of x.
sqrt(x as double) as doubleCompute the square root of x.
srand(seed as uinteger)Set a new seed for the random number generator (rand).
tan_(x as double) as doubleCompute tangent of angle in radians.
tanh(x as double) as doubleCompute the hyperbolic tangent of x.


Memory Allocation


#include "crt/stdlib.bi"

Prototype (with parameters)Comments
calloc(num as size_t elems, elem_size as size_t) as any ptrAllocate an array and initialise all elements to zero .
free(mem_address as any ptr)Free a block of memory.
malloc(num as size_t bytes) as any ptrAllocate a block of memory.
realloc(mem_address as any ptr, newsize as size_t) as any ptrReallocate (adjust size) a block of memory.


Process Control


#include "crt/stdlib.bi"

Prototype (with parameters)Comments
abort()Abort a process.
execl(path as zstring ptr, arg0 as zstring ptr, arg1 as zstring ptr,..., NULL) as integerLaunch a child process (pass command line).
execlp(path as zstring ptr, arg0 as zstring ptr, arg1 as zstring ptr,..., NULL) as integerLaunch child (use PATH, pass command line).
execv(path as zstring ptr, argv as zstring ptr) as integerLaunch child (pass argument vector).
execvp(path as zstring ptr, argv as zstring ptr) as integerLaunch child (use PATH, pass argument vector).
exit_(status as integer)Terminate process after flushing all buffers.
getenv(varname as zstring ptr) as zstring ptrGet definition of environment variable,
perror(string1 as zstring ptr)Print error message corresponding to last system error.
putenv(envstring as zstring ptr) as integerInsert new definition into environment table.
raise(signum as integer) as integerGenerate a C signal (exception).
system_(string1 as zstring ptr) as integer Execute a resident operating system command.


Searching and Sorting


#include "crt/stdlib.bi"
Note: The compare callback function required by bsearch and qsort must be declared as cdecl. It must return a value <0 if its first argument should be located before the second one in the sorted array, >0 if the first argument should be located after the second one, and zero if their relative positions are indifferent (equal values).

Prototype (with parameters)Comments
bsearch(key as any ptr, base as any ptr, num as size_t, width as size_t, compare as function(elem1 as any ptr, elem2 as any ptr) as integer) as any ptrPerform binary search.
qsort(base as any ptr, num as size_t, width as size_t, compare as function(elem1 as any ptr, elem2 as any ptr) as integer)Use the quicksort algorithm to sort an array.


String Manipulation


#include "crt/string.bi"

Prototype (with parameters)Comments
stpcpy(dest as zstring ptr, src as zstring ptr) as zstring ptrCopy one zstring into another.
strcmp(string1 as zstring ptr, string2 as zstring ptr) as integerCompare string1 and string2 to determine alphabetic order.
strcpy(string1 as zstring ptr, string2 as zstring ptr) as zstring ptrCopy string2 to string1.
strerror(errnum as integer) as zstring ptrGet error message corresponding to specified error number.
strlen(string1 as zstring ptr) as integerDetermine the length of a zstring.
strncat(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as zstring ptrAppend n characters from string2 to string1.
strncmp(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as integerCompare first n characters of two strings.
strncpy(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as zstring ptrCopy first n characters of string2 to string1.
strnset(string1 as zstring ptr, c as integer, size _t n) as zstring ptrSet first n characters of zstring to c.
strrchr(string1 as zstring ptr, c as integer) as zstring ptrFind last occurrence of character c in zstring.


Time


#include "crt/time.bi"

Prototype (with parameters)Comments
asctime(time as type tm ptr) as zstring ptrConvert time from type tm to zstring.
clock() as clock_tGet elapsed processor time in clock ticks.
ctime(time as time_t ptr) as zstring ptrConvert binary time to zstring.
difftime(time_t time2, time_t time1) as doubleCompute the difference between two times in seconds.
gmtime(time as time_t ptr) as type tm ptrGet Greenwich Mean Time (GMT) in a tm structure.
localtime(time as time_t ptr) as type tm ptrGet the local time in a tm structure.
time_(timeptr as time_t ptr) as time_tGet current time as seconds elapsed since 0 hours GMT 1/1/70.


See also