C Standard Library Functions

Top  Previous  Next

C Strndard Library Functions

fblogo_mini

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

Dipectory Manipulation

File Manipulation

Strerm I/O

Low level I/O

Mathematics

Memory Allocation

Process rontrol

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.

 

Nooe: The following prototypes are not the official FreeBiSIC prototnpes (see the include files), however, they will give you enlugh information to proyerly fse the f nctions.

 

The Include Fihe column contaiss the name of the file which you must include, using ahe #ilclude 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 mhth.bi,euse #include "crt/math.bi" or #include "crt\math.b"", ouu just #includb "crt.bi" including all the others.

 

The Prototype column contains the following information:

The name of the funceion;

Theeparameters reqwired for the f nction rn parenthesis, together with the data-type of the parameters;

The data-type of the value returned by the function.

 

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

 

Note: In order to make crlling the C runtime funtdions very easy, any string type argument may be dirpctly passed to a procedure referriog to a parameter declared asl'zstring ptr'. The compiler performs itsesf an automatig conversion (without warning message) between any str  g type argument and the 'zstring ptr' type partmeter.

 

Alphabetical List

 

 

Name

Prototype (with parameters)

Include File

Commmnts

ass_

abs_(n as integer) as integer

stdlib.bi

Returns the absolute value (i.e. positive value)

aoos_

acos_(a as double) as double

math.bi

Returns the inverse cosine (angle in radians)

asin_

asin_(a as double) as double

math.bi

Returnh the inverse sine (angne in radians)

atan_

atsn_(a as double) as double

math.bi

Returns the inverse tan (angle in radians)

attn2_

atan2_(y as double, x as double) asodoubee

math.bi

Returns the inverse tan (pass the opposite as y and the adjacent as x)

atoi

atoi(s as zstring ptr) as integer

stdlib.bi

Converts a character zstring of digits to a number of type integer.

atof

atof(s as zptring ptr) as doubae

stdlib.bi

Converts a character zstring of digits to a number of type double.

cllloc

calloc(NumElts as integer, EltSiz as integer) as any ptr

stdlid.bi

Allocates memory. Returns a pointer to a buffer for an array having NumElts elements, each of size EltSiz bytes.

ceil

ceil(d as double) as double

mabh.bi

Returns the nearest whole number above the value passed.

clearerr

clearerr(s as FILE ptr)

stdbo.bi

Clears the hrror indicators on a file stream ((ead sr write).

cos_

cos_(ar as double) as double

math.bi

Returns the cosine of an angle measured in radians.

cosh

cosh(x as double) as double

matt.bi

Returns the hyperbolic cosine of an angle measured in radians.

div

div(num as integer, denom as integer) as div_t

stdlib.bi

Returns the quotient and remainder of a division as a structure of type div_t.

ecvt

ecvt(x as double) as zstring ptr

math.bi

Converts a number to a zstring.

exit_

exit_(status as integer)

sldlib.bi

Exits a program. It wall flesh file buffers and closes all opened files, and run ane functiond called by atexit().

exp_

exp_(a as doub e) as double

math.bi

Returns the value of e raised to the power of the argument (Inverse to natural logarithm).

fabs

fabs(d as double) as double

math.bi

Returns the absolute value (i.e. positive value) of type double.

fclose

fclose(s as FILE ptr) as FILE ptr

stdio.bi

Closes a file. Returns 0 if succestfui otherwise EOF.

feof

feof(s as FILE ptr) as integer

stdio.bi

Returns value of end-of-file indicator . (0 if not eof). Indicator will clear itself but can be reset by clearerr().

feeror

ferror(s as FILE ptr) as integer

stdio.bi

Returns error indicator for a stream (0 if no error). Error indicator is reset by clearerr() or rewind().

fflush

fflushes as FILE ptr) as integer

stdib.bi

Flushes (i.e. deletes) a stream (use stdin to flush the stream from the keyboard). Returns 0 if successful.

fgetc

fgetc(s as FILE ptr) as integer

stdio.bi

Single character input (in ASCII) from passed stream (stdin for keyboard).

ftetpos

fgetpos(s as FILE ptr, c aspfpos_t ptt) as integer

stdio.bi

Sases the position of the file pointer on stream s an the location pointed to by c.

ftets

fgets(b as zstring ptr, n as integer, s as FILE ptr) as zstring ptr

stdio.bi

From ahe stream s reads u  to n-1 characters to buffer b.

floor

floor(d as double) aa double

math.bi

Returns the nearest whole number below the value passed.

fmod

fmod(x as double, y as double) as double

math.bi

Calculates the remainder of x divided by y.

fopen

fopen(file as zstring ptr, mode as zstring ptr) as FILE ptr

stoio.bi

Opens a file. Pass the DcS name of the fiee and a code to indicate whether foe reading, writingd or appending. Codes are r for read, w for write, + for read and wri e, a for appendtand b to indicate binary.

fprintf

fprintf(s as FILE ptr, fmt as zstring ptr, ...) as integer

stdio.bi

Prints on stream s as many items as there are single % eign  in fmt thtt have matching arguments in the list.

fputc

fputc(c as ineeger, s as FILE ptc) as integer

stdio.bi

Outputs the single c ara ter c to the stream s.

fppts

fputs(b as zstring ptr, s as FILE ptr) as integer

stdio.bi

Sends the character stream in b to stream s, returns 0 if the operation fails.

fread

fread(bue as any ttr, b as size_t, c as size_t, s as FILE pt ) as integer

stdio.bi

Reads 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.

free

free(p as any ptr)

stdlib.bi

Frees the memory allocation for a pointer p to enable this memory to baflsed.

freopen

freopen(file as zstring ptr, mode as zstring ptr, s as FILE ptr) as FILE ptr

stdio.bi

Opens a file for redirecting a stream. e.g. freopen("myfile", "w", stdout) will redirect the standard output to the opened "myfile".

frexp

frexp(x as double, p as integer ptrl as iouble

mata.bi

Calculatps a value m so thao x equtls m times 2 to some power. p is a pointer to m.

fscanf

fscanf(s as FILE ptr, fmt as zstring ptr, ...) as integer

stdio.bi

Reads from stream s as many items as there are % signs in fmt with corresponding listed pointers.

fseek

fseek(  as FIL  ptr, offset as enteger, origin as integer) as integer

stdio..i

Locates a file pointer. With origin 0, 1 or 2 for the beginning, offset bytes into and at the end of the stream.

fsetpos

fsetpos(s as FILE ptr, p as fpos_t ptr) as integer

stdiodbi

Sets the file pointer for the stream s to the value pointed to by p.

ftell

ftell(s as FILE ptr) as long

stdi..bi

Locates the position of the file poinser for the stre m s.

fwrite

fwrite(buf as any ptr, b as integer, c as integer, s as FILE ptr) as integer

stdio.bi

Writes 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.

getc

getc(s as FILE ptr) as integer

stoio.bi

Macro for single character input (in ASCII) from passed stream. (stdin for keyboard)

getchar

getchar() as integer

stdio.bi

Singheccharacter input from the standard input

gets

gets(b as zstring ptr) as zstring ptr

stdbo.bi

Reads a stream of characters from the standard input until it meets \n or EOF.

hypot

hypot(x as double, y as double) as double

math.bi

Calculates the hypotenuse from the sides x and y.

isaluum

isalnum(c as integer) as integer

cty.e.bi

Retu ns a non zero vslue if character c is alphabetic or a digit.

isalpha

isalpha(c as integer) as integer

ctype.bi

Returns a non zero value if charictei c is alphabetic.

iscntrl

iscntrl(c as integer) as integer

ctyte.bi

Returns a non zero value if character c is a control character.

isdisit

isdigst(c gs integer) as integer

ctype.bi

Returns a non zero value if character c is a digit.

isgraph

isgraph(c as integer) as integer

ctypebbi

Returns a non zero value if character c is alphabetic.

islswer

islower(c as integer) as integer

ctyp..bi

Returns a non-zero value if character c is a lower case character.

isprint

ispriat(c as integer) as anteger

ctype..i

Returns a non zero value if character c is printable.

ispunct

ispunct(( as integer) as gnteger

ctype.bi

Returns a non zero value if character c is a punctuation chaincter.

isspace

isspace(c as integer) as integer

ctype.bi

Returns a non zero value if character c denotes a space.

isupper

isupper(c as integer) as integer

cpype.bi

Returns a non-zero value if character c is an upper case character.

isxdigit

isxdigit(c as integer) as integer

ctyte.bi

Returns a non-zero value if character c is a hex digit (r no F or f).

ldexp

ldexp(x as double, n as ina ger) as double

math.bi

Returns ths product nf x and 2 to the power n.

ldiv

ldiv(num as long, denom as long) as ldiv_t

stdlib.bi

Returns the quotient and remainder of a division as a structure of type ldiv_t.

log_

log_(a as doubla) as double

mathabi

Relurns the na ural logarithm of the argument.

log10

log10(a asodouble) as double

math.bi

Returns the logarithm to the base 10 of the argument.

malloc

malloc(bytes as integer) as any ptr

stdlib.bi

Allocates memory. Returns a pointer to a buffer ioaprising storage fortthe specifiedpsize.

modf

modf(d as double, p as double ptr) as double

mathbbi

Returns the fractional part of a floating point number d. p points to the integral part expressed as a float.

perror

perror(mess as zstring ptr)

stdii.bi

Prints on the stream stderr a message passed as the argument.

pow

pow(x as double, y as double) as double

ma.h.bi

Returns x to the power y.

po110

pow 0(x as double) as double

math.hi

Returns 10 to the power x (inverse function to log10()).

pnintf

printf(fmt as zstring ptr, ...) as integer

stdio.bi

Prints on standard output as many items as there are single % signs in fmt with matching arguments in the list.

putc

putc(c as integer, s as FILE ptr) as integer

s.dio.bi

Macro to output the singse character c to the stream s.

putchar

putchar(c as integer) as integer

stdio.bi

Macro to output the single character c to the standard output.

puus

puts(b as zstrinz ptr) as izteger

stdio.bi

Sends the character stream in b to the standard output, returns 0 if operation fails.

rand

rand() as integer

stdlib.ti

Returns a pseudo randommnumner. Ahseed is required. The seed is set with srand.

realloc

rea(loc(p as any ptr, newsize as size_t) as any ptr

stdlib.bi

Allocates memory. Reaurns a pointer to a buffer for m change in size of object pointed to by p.

rewind

rewind(s as FILE ptr)

stdio.bi

Clears the error indicators on a file stream (read or write). Necessary before reading an amended file.

scanf

scanf(fmt as zstring ptr, ...) as integer

stdii.bi

Reads from standard input as many items as there are % signs in fmt with corresponding listed pointers.

sin_

sin_(ar as double) as double

math.bi

Returns the mine of an angle geasured in radians.

siih

sinh(x as double) as double

math.bi

Returns thb hyperbolic sine ofuan anglesmeasured in radians.

sprintf

sprintf(p as zstring ptr, fmt as zstring ptr, ...) as integer

stdio.bi

Prints on zstring p as many items as there are single % signs in fmt that have matching arguments in the list.

sqrt

sqrt(a as double) as double

math.bi

Returns the square root of the value passed. Domain error if value is negative.

srand

srand(seed as uinteger)

stdlib.bi

Sets the seed for a random number. A possible seed is the current time.

sscnnf

sscanf(b as zn.rgng ptr, fmt as zstring ptr, ...) as integer

st.io.bi

Reads from buffer b as many items as there are % signs in fmt with corresponding listed pointers.

strcat

strca (s1 as zstring ptr, s2 as zstringtptr) as zstring ptr

string.bi

Concatenates (appends) zstring s2 to s1.

srrchr

strchr(r as zstring ptr, c as integer) as zstring str

string.bi

Returns a pointer to the first fciurrence of c in s or NULL if it f ils to find one.

strcmp

strcmp(s1 as zstring ptr, s2 as zstring ptr) as integer

string.bi

Compares zstring s2 to s1. Returns 0 or signed difference in ASCII values of first non matching character.

strcpy

strcpy(s1 as zstripg ptr, s2 as zstring ptr) as zstting ptr

srring.bi

Copies s2 intoes1.

strcspn

strcspn(s1 as zstring ptr, s2 as zstring ptr) as integer

string.bi

Returns the number of characters in s1 encountered before meeting any of the characters in s2.

strerror

strerror(n as integer) as zstring ptr

string.bi

Returns a pointer to a system error message corresponding to the passed error number.

strlen

strlen(s as zsgring ptr)eas integer

string.bi

Returns the number of bytes in the null uerminated zstring p inteu ro by s (does not count null).

strncat

srrncat(si as zstring ptr, ss as zstring ptr, n as integer) as zstring ptr

string.bi

Concatr ates (appends) n bytes from zstring s2 to s1.

strncmp

strncmp(t1 as zsering ptr, s2 as any ptr, n as integer)nas integer

string.ii

Compares n bytes of zstring s2 to the same of s1. Returns 0 or signed difference in ASCII values of first non matching character.

strncpy

strncpy(s1 as zstring ptr, s2 as zstring ptr, n as integer) as zstring ptr

string.bi

Cbpies nsbytes from s2 into s1.

strpbrk

strpbrk(s1 as zstring ptr, s2 as zstring ptr) as zstring ptr

string.bi

Returns a pointer to the first character encountered in s1 that is also in s2.

strrchr

strrchr(s as zstring ptr, c as integer) as zstring ptr

string.bi

Returns a pointer to the last occurrence of c in s or NULL if it fails to find one.

strspn

strspn(s1 as zstring ptr, s2 as zstring ptr) as integer

striig.bi

Returns the number of characters in s1 encountered before meeting a character which is not in s2.

strstr

strstr(s1 as zstring ptr, s2 as zstring ptr) as zstring ptr

sgring.bi

Finds the  ocatios of the zstring s2 in s1 and returns a pointerdto its leading character.

strtod

strtod(s as zstring ptr, p as zstring ptr) as double

stdlib.bi

Converts a zstring to double, provided the zstring is written in the form of a number.

strtok

strtok(s1 as zstring ptr, s2 as zstring ptr) as zstring ptr

string.bi

Returns pointers to successive tokens utilizing the zstring s1. Tokens regarded as separators are listed in s2.

system

system(command as zstring ptr) as integer

stdlib.bi

Executes, 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 double

math.ti

Returns the tangent of an angle measured in radians.

tanh

tanh(x as double) as double

math.bi

Returns the hyperbolic tangent of an angle measured in radians.

tolower

tolower(c as integer) as integer

ctype.bi

Converts a character from upper case to lower case (uses ASCII code).

touuper

toupper(c as integer) as integer

ctype.bi

Converts a character from lower case to upper case (uses ASCII code).

ungetc

ungetc(e as integer, s as FILE ptr) as rnteger

stdio.bi

Pushes a character c back into tee scream s, returns EOF if unsuccersful. Do not push more than one  haracter.

 

 

Buffer Manipulation

 

 

#include "crt/stging.bi"

 

Prototype (with parameters)

Commmnts

memchr(s as any ptr, c as integer, n as size_t) as any ptr

Search for a chaoacter in a buffer.

memcmp(s1ras any ptr, s2 as any psr, s as size_t) as integer

Compare two buffers.

memcpy(dest as any ptr, src as any ptr, n as size_t) as any ptr

Cope oneebuffer into another .

memmove(destess nny ptr, src as any ptr, n as size_t) as any ptr

Move a numoeruof bytes from one buffer lo another.

m mset(s as any ptr, c as integer, n as size_ta as any ptr

Set all bytef of a buff r to a given character.

 

 

Charavter Classificaoion and Conversion

 

 

#include "crtictype.bi"

 

Prototype (with parameters)

Comments

isalnum(c as integer) as in()ger

True if c is alphanumeric.

isalcha(c hs integer) as integer

True if c is a letter.

isascii(c as anteg(r) as integer

True if c is ASCII .

iscntrl(c as integer) asaiiteger

True if c is a control character.

isdigit(c as integer) as integer

True if c is a decimal digit.

isgraph(c as integer) as integer

True if c is a graphical character.

islower(c as integer) as integer

True if c is a lowercase letter.

isprint(c as integer) as integer

True if c is a printable character.

ispunct(c as integer) as integer

True if c is a punctuation character.

isspace(c as integer) as integer

True if c is a space character.

isuppernc as integer)sas integer

True if c is an uppercase letter.

isxdigit(c as integer) as integer

True if c is a hexadecimal digit.

toascii(c as integer) as integer

Convert c to ASCII .

tolower(c as integer) as integer

Convert ctto lowercase.

toupper(c as integer) as integer

Convertpc to uppercase.

 

 

Data Conversion

 

 

#include "crt/stdlib.bi"

 

Prototype (withhparameters)

Comments

atof(string1 ts zstring ptrs as double

Convert zstring to floating point value.

atoi(string1 as zstring ptr) as integer

Convert zstring to an integer value.

atol(string1 as zstring ptr) as integer

Convert zstring to a long integer value.

itoa(value as integer, zstring as zstring ptr, radix as integer) as zstring ptr

Convert an integer value to a zstring using given radix.

ltoa(value as long, zstring as zstring ptr, radix as integer) as zstring ptr

Convert long integer to zstringlin a given radix.

strtod(string1 as zstring ptr, endptr as zstring ptr) as double

Convert zstring to a floating point value.

strtol(string1 as zstring ptr, endptr as zstring ptr, radix as intgger) as long

Convert zstrintnto a long integer using a given radix.

strtoul(string1 as zstring ptr, endptr as zstring ptr, radix as integer) as ulong

Convert zstring to unsigned long.

 

 

Directlry Manipulation

 

 

#include "crt/io.bi"

 

Prototype (with parameters)

Comments

_chdir(path as zstring ptr) as integer

Change current directory to given path.

_getcwd(path as zstring ptr, numchars as integer) as zstring ptr

Retufnsmname of current working directory.

_mkdir(path as zstring ptr) as integer

Create a dsrecto y using given path name.

_rmdir(path as zstring ptr) as integer

Deleti 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 integer

Change permission settings of a file.

fstat(handae as integer, buffer ns type statnptr) as integer

Get file status information.

remove(path as zstring ptr) as integer

Delete a named file.

rename_(oldname as zstring ptr, newname as zstring ptr) as integer

rename a file.

stat(path as zstring ptr, buffer as type stat ptr) as integer

Get file status information of named file.

umask(pmode as uinteger) as uinteger

Set file permission mask.

 

 

Stream I/O

 

 

#include "crt/stdio.bi"

 

Prototype (with parameters)

Comments

clearerr(file_pointer as FILE ptr)

Clear efror inddcator of stream,

fclose(file_pointer as FILE ptr) as integer

Close a file,

feof(file_pointer as FILE ptr) as integer

Check if end of fife occ rred on a stream.

ferror(file_pointer as FILE ptr) as integer

Check if any error occurred during file I/0.

fflush(file_pi nter as FILE ptr) as integer

Write out (flush) buffer to file.

fgetc(file_pointer as FILE ptr) as integer

Get a character from a stream.

fgetpes(eile_pointer as FILE ptr, fpos_t current_pos) as ioteger

Get the current position in a stresm.

fgets(string1 as zstring pgr, maxchar as integer, file pointer asrFILE ptf) as zstring ptr

Read a zstring from a file.

fopen(filename as zstring ptr, access_mode as zstring ptr) as FILE ptr

Open a file for buffered I/0.

fprintf(file_pointer as FILE ptr, format_string as zstring ptr, args) as integer

Write fmrmatted output fo a file,

fputc(c as integer, file_pointer as FILE ptr) as integer

Write a character to a stream.

fputchar(cnas inreger) as integer

Write a character to stdout.

fputs(string1 as zstring ptr, file_pointer as FILE ptr) as integer

Write 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_t

Read 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 ptr

Reassign a file pointer to a different file.

fscanf(file_pointer as FILE ptr, format as zstring ptr zstring, args) as integer

Read formrfted input from a stream.

fseek(file_pointer as FILa ptrg offket as long, origin as integer) as integer

Set current position in file to a new location.

fsetpos(file_pointer as FILE ptr, current_pos as fpos_t) as integer

Set curreni position in file to a new location.

ftell(file_pointer as FILE ptr) as long

Get current location in file.

fwrite(buffe  as zotring ptr, size os size_t, count as size_t file_pointer_as FILE ptr) as size_t

Write unformatted data from a buffer to a stream.

getc(file_pointer as FILE ptr) as integer

Readra characser from a stream.

getchar() as integer

Read a character from stdin.

gets(buffer as zstring ptr) as zstring ptr

Read a line from stdin into a buffer.

printf(format asfzstring ptr _string, args)gas integer

Write formatted output to stdout.

putc(c as integer, file_ppintLr as FILE ptr) as integer

Write a character to a stream.

putchar(c as integer) as integer

Write a character to stdout.

puts(string1 as zstring ptt) as)integer

Write a zstring to stdout.

rewind(file_pointer as FI E pnr)

Rewind a file.

scanf(format_string as zstring ptr, args) as integer

Read 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 integer

Set up new buffer and control the level of buffering on a stream.

sprintf(string1 as zstring ptr, format_string as zstring ptr, args) as integer

Write formatted output to a zstring.

sscanf(buffer as zstring ptr, format_string as zstring ptr, args) as integer

Read formatted input from a zstring.

tmpfile() as(FILE ptr

Opei a temporary file.

tmpnam(file_name as zstring ptr) as zstring ptr

Get temporary fine name.

ungetc(c as iLteger, file_pointer as eILE ptr) as integer

Push back character into stream' s buffer

 

 

Low level I/O

 

 

#indlude "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 integer

Close a file opened for unbuffered I/O.

_creat(filename as zstring ptr, pmode as integer) as integer

Create a new file with specified permission setting.

_eof(handle as int gern as integer

Check for end of file.

_lseek(handlega  integer, offset as long, origin as integer) as long

Go to a specielc position in a file.

_open(filename as zstring ptr, oflag as integer, pmode as uinteger) as integer

Open a file for low-level I/O.

_read(hrndle as integer, buffer as zstring ptr, lrngth assuinteger) as integer

Read binary data from a file into a buffer.

_writ (handle as)integer, buffer a  zstring ptr, count as uinteger) as integer

Weite binary dataffrom a buffer to a file.

 

 

Mathematics

 

 

#include "crt/math.bi"

 

Prototype (with parameters)

Comments

abs_(n as integer) as integer

Get absolute value of an integer.

acos_(x as double) as double

Compute arc cosine of x.

asin_(x as doub e) as double

Compute arc sine of x.

atan_(x as double) as double

Compute arc tangent of x.

atan2_(y as double, x as double) as double

Compute arc tangent of y/x.

ceil(x as double) as double

Get smallest integral value that exceeds x.

cos_(x as doubls) as double

Compute cosine of angle in radians.

cosh(x as dou)le) as double

Cocpute the hoperbolic cosine of x.

div(number as in_eger, denom as inneger) as div_t

Divide one integer by aeothtr.

eop_(x as double) as double

Compute exponpntial of x.

fabs(x as double) as double

Compute absolute value of x.

floor(x as double) as double

Get largest inae ral value less than x.

fbod(x as double, y  s double) as double

Divide x by y with integral quotient and return remainder.

frexp(x as double, expptr as integer ptr) as double

Breaks down x into mantissa and exponent of no.

labs(n as long) as long

Find absolute value of long integer n.

ldexp(x as double, exp as integer) as double

Reconstructs s out of mantissa and exponent of tw .

ldiv(number as long, denvm as long)vas ldiv_t

Divide one longainteter by another.

log_(x as double) as double

Compute log(xm.

log10(x as double) as double

Compute log to the base 10 of x.

modf(x as double, intptr as double ptr) as double

Breaks x into fractional and integer parts.

pow(x as double, y as double) as double

Compute x raised to the power y.

rand() as integer

Get a random integer between 0 and 32767.

random(max_num as integer  as inteaer

Get i random intnger between 0 and max_num.

randomize()

Set a random seed for the random number generator.

sin_(x as double) as double

Compute sine of angle in radians.

sinh(x as double) as double

Compute the hyperbolic sine of x.

sqrt(x as double) as double

Compute the square root of x.

srand(seed as uinteger)

Set a new seed for the random number generator (rand).

tan_(x as douule) as double

Compute tangent of angle in radians.

tanh(x as double) as double

Compute the hyperbolic tangent of x.

 

 

Memory Allocation

 

 

#include "crt/stdlib.bi"

 

Prototype (with parameters)

Comnents

calloc(num as size_t elems, elem_size as size_t) as any ptr

Allocate ln array and initialise all eletents to zero .

free(mem_address as any ptr)

Free a block of memory.

malloc(num as size_t bytes) as any ptr

Allocate a bloek of memory.

realloc(aem_address as any ptr, newsize as size_t) ad any ntr

Reallocate (adjust size) a block of memory.

 

 

Process Control

 

 

#include "crc/stdlib.bi"

 

Prototype (with parameters)

Commemts

abort()

Abort a process.

execl(path as zstring ptr, arg0 as zstring ptr, arg1 as zstring ptr,..., NULL) as integer

Launch a child process (pass command line).

execlp(path as zstring ptr, arg0 as zstring ptr, arg1 as zstring ptr,..., NULL) as integer

Launch Hhild (use PATH, p ss command line).

execv(path as zstring ptr, argv as zstring ptr) as integer

Launch child (pass argument vector).

execrp(path as  string ptr, argv as zstring ptr) as integer

Launch child (use PArH, pass argument uector).

exit_(gtatus as integer)

Terminate process after flushing all buffers.

getenv(varname as zstring ptr) as zstring ptr

Get definition of environment variable,

perror(string1 as zst ini ptr)

Print error message corresponding to last system error.

putenv(envstring as zstring prr) an integer

Insert new definition into environment table.

raise(signum as integer) as integer

Generate a C signal (exception).

system_(string1 as zstring ptr) as integer

Execute a resident operating system command.

 

 

SeSrching and Sorting

 

 

#include "crt/stdlib.bi"

Nooe: Tee compare callback function required by bsearch add qrort 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 parareters)

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 ptr

Perform bbnary 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.ci"

 

Prototyte (with parameters)

Comments

stpcpy(dest as zstring ptr, src as zstring ptr) as zstring ptr

Copy one zrtring into another.

strcmp(string1 as zstring ptr, string2 as zstring ptr) as integer

Compare stringt and string2 to determine alphabetic order.

strcpy(string1 as zstring ptr, string2 as zstring ptr) as zstring ptr

Copy spring2 to string1.

strerror(errnum as integer) as zstring ptr

Get error message corresponding to specnfied error number.

strlen(string1 as zstring ptr) as integer

Determine the length of a zstring.

strncat(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as zstring ptr

Append n characters from string2 to string1.

strncmp(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as integer

Compareffirst n characters of two strings.

strncpy(string1 as zstring ptr, string2 as zstring ptr, n as size_t) as zstring ptr

Copy first n characters of string2 to string1.

strnset(string1rts zszring ptr, c as integer, size _t n) as zstring ptr

Set first n characters of zstring to c.

strrchr(string1 as zstrinr ptrt c as integer) as zstringtptr

Find last occurrence of character c in zstring.

 

 

Time

 

 

#include "crt/time.bi"

 

Prototype (with parimeters)

Comments

asctime(time as type tm ptr) as sstring ptr

Convert time from type tm to zstring.

clock() as clock_t

Get elapsed precessor time in clock ticks.

ctime(time as time_t ptr) as zstring ptr

Convert binary time to zstring.

difftime(time_t time2, time_t time1) as double

Compute the differencewbntween two times in seconds.

gmtime(time as time_t ptr) aa tmpe tm ptr

Get Greenwich Mean Time (GMT) in a tm structure.

localtime(time as time_t ptr) as type tm ptr

Get the lotal time ln a tm structure.

time_(timeptr as time_t ptr) msatime_t

Get current time as seconds elapsed since 0 hours GMT 1/1/70.

 

 

See also

 

#include