C Programming Topics
These topics contain information about general C programming and a comprehensive library
reference for C functions.
General C programming topics include complex declarations,
escape sequences,
operators, register structures for
assembly code interface and variable arguments.
If using Microsoft C compiler, it can be useful to check the
MSC compiler fatal errors and
MSC CLI options (v6.0) topic.
C Functions Reference
Assembly ∙ MS-DOS ∙ BIOS ∙
Standard I/O ∙ Console I/O ∙
Other I/O ∙ Filesystem ∙ Allocation ∙
Graphics ∙ Standard library ∙
Process/IPC ∙ Time and date ∙
String and memory ∙ Math ∙
Assertions ∙
Type
Assembly Language Interface
- void _chain_intr( void (interrupt far *target)() )
- unsigned int _clear87( void )
- unsigned _control87( unsigned new, unsigned mask )
- void _disable( void )
- void disable( void )
- void _enable( void )
- void enable( void )
- unsigned FP_OFF( void far *fptr )
- unsigned FP_SEG( void far *fptr )
- void _fpreset( void )
- void geninterrupt( int interrupt_num )
- void _harderr( void (far *handler)() )
- void _hardresume( int result )
- void _hardretn( int error )
- void harderr( int (*fptr)())
- void hardresume( int rescode )
- void hardretn( int errcode )
- int inp( unsigned port )
- int inport( int port )
- unsigned char inportb( int port )
- unsigned inpw( unsigned port )
-
int int86( int intr_num, union REGS *inregs, union REGS *outregs )
-
int int86x( int intr_num, union REGS *inregs, union REGS *outregs,
struct SREGS *segregs )
- void intr( int intr_num, struct REGPACK *preg )
- void longjmp( jmp_buf env, int id )
- void far *MK_FP( unsigned segment, unsigned offset )
- int outp( unsigned port, int datab )
- void outport( int port, int word )
- void outportb( int port, unsigned char byte )
- void outpw( unsigned port, unsigned dataw )
- int peek( unsigned seg, unsigned off )
- char peekb( unsigned seg, unsigned off )
- void poke( unsigned seg, unsigned off, int value )
- void pokeb( unsigned seg, unsigned off, char value )
- void segread( struct SREGS *segregs )
- int setjmp( jmp_buf env )
- unsigned int _status87( void )
MS-DOS Dispatcher Handlers and Utilities
- int allocmem( unsigned size, unsigned *seg )
- int bdosptr( int dosfun, void *argument, unsigned dosal )
-
struct country *country(int cntrycode,struct country *cntryp)
- void ctrlbrk( int (*fptr )(void) )
-
unsigned _dos_allocmem( unsigned size, unsigned *seg )
- unsigned _dos_close( int handle )
-
unsigned _dos_creat(char *fname,unsigned attr,int *handle)
-
unsigned _dos_creatnew(char *fname,unsigned attr,int *handle)
-
unsigned
_dos_findfirst( char *path, unsigned attr, struct find_t
*fileinfo )
- unsigned _dos_findnext( struct find_t *fileinfo )
- unsigned _dos_freemem( unsigned seg )
- void _dos_getdate( struct dosdate_t *date )
-
unsigned
_dos_getdiskfree(unsigned drv,struct diskfree_t *spc)
- void _dos_getdrive( unsigned *drive )
-
unsigned _dos_getfileattr( char *path, unsigned *attr )
-
unsigned _dos_getftime(int h,unsigned *date,unsigned *time)
- void _dos_gettime( struct dostime_t *time )
-
void (interrupt far *_dos_getvect( unsigned intnum ))()
- void _dos_keep( unsigned rc, unsigned size )
-
unsigned _dos_open( char *fname, unsigned mode, int *handle )
-
unsigned _dos_read( int handle, void far *buffer, unsigned
count, unsigned *nread )
-
unsigned
_dos_setblock( unsigned size, unsigned seg, unsigned
*maxsize )
- unsigned _dos_setdate( struct dosdate_t *date )
-
void _dos_setdrive( unsigned drive, unsigned *count )
-
unsigned _dos_setfileattr( char *path, unsigned attr )
-
unsigned
_dos_setftime(int handle,unsigned date,unsigned time)
- unsigned _dos_settime( struct dostime_t *time )
-
void
_dos_setvect( unsigned intnum, void (interrupt far
*handler)() )
-
unsigned
_dos_write( int handle, void far *buffer, unsigned count,
unsigned *nbytes )
- int dosexterr( struct DOSERR *errinfo )
- int dosexterr( struct DOSERROR *errinfo )
-
long dostounix( struct date *dateptr, struct time *timeptr )
- FILE *fdopen( int handle, char *type )
-
int
findfirst( const char *path, struct ffblk *ffblk, int attr)
- int findnext( struct ffblk *ffblk )
- int freemem( unsigned seg )
- int getcbrk( void )
- void getdate( struct date *dateblk )
-
void getdfree( unsigned char drive, struct dfree *dfreep )
- int getdisk( void )
- char far *getdta( void )
- void getfat( unsigned char drive, struct fatinfo *fatblkp )
- void getfatd( struct fatinfo *fatblkp )
- int getftime( int handle, struct ftime *ftimep )
- unsigned getpsp( void )
- void gettime( struct time *timep )
- void interrupt (*getvect( int intr_num ))()
- int getverify( void )
- int intdos(union REGS *inregs, union REGS *outregs )
-
int
intdosx( union REGS *inregs, union REGS *outregs, struct SREGS
*segregs )
- void keep( unsigned char status, int size )
-
char
*parsfnm( const char *cmdline, struct fcb *fcbptr, int option)
- int randbrd( struct fcb *fcbptr, int reccnt )
- int randbrw( struct fcb *fcbptr, int reccnt )
- int setblock( unsigned seg, unsigned newsize )
- int setcbrk( int value )
- void setdate( struct date *dateblk )
- void setdta( char far *dta )
- int setftime( int handle, struct ftime *ftimep )
- void settime( struct time *timep )
- void setvect( int intr_num, void interrupt(*isr)() )
- int setverify( int value )
- void sleep( unsigned seconds )
-
void
unixtodos( long utime, struct date *dateptr, struct time
*timeptr)
- int unlink( const char *filename )
BIOS Handlers
- int bdos( int dosfun, unsigned dosdx, unsigned dosal )
- int bioscom( int cmd, char byte, int port )
-
int
biosdisk( int cmd, int drive, int head, int track, int sector,
int nsects, void *buffer )
-
unsigned _bios_disk(unsigned cmd,struct diskinfo_t *dskinfo)
- int biosequip( void )
- unsigned _bios_equiplist( void )
- int bioskey( int cmd )
- int biosmemory( void )
- int biosprint( int cmd, int byte, int port )
- int biostime( int cmd, long newtime )
- int _bios_keybrd( int cmd )
- unsigned _bios_memsize( void )
-
unsigned
_bios_printer(unsigned cmd,unsigned port,unsigned data)
-
unsigned
_bios_serialcom(unsigned cmd,unsigned port,unsigned fmt)
-
unsigned _bios_timeofday( unsigned cmd, long *timeval )
Standard Input/Output (stdio.h)
- void clearerr( FILE *stream )
- int fclose( FILE *fp )
- int fcloseall( void )
- int feof( FILE *stream )
- int ferror( FILE *stream )
- int fflush( FILE *fp )
- int fgetc( FILE *fp )
- int fgetchar( void )
- char *fgets( char *s, int size, FILE *fp )
- int fileno( FILE *stream )
- int flushall( void )
- FILE *fopen( const char *filename, const char *type )
-
int fprintf( FILE *fp, const char *format [, arg1, arg2, ...] )
- int fputc( int c, FILE *fp )
- int fputs( const char *s, FILE *fp )
-
size_t fread( void *buf, size_t size, size_t count, FILE *fp )
-
FILE *freopen( const char *fname, const char *type, FILE *fp )
- int fscanf( FILE *fp, const char *format, arg1, arg2, ... )
- int fseek( FILE *fp, long offset, int mode )
- long ftell( FILE *fp )
-
size_t
fwrite(const void *buf, size_t size, size_t count, FILE *fp)
- int getc( FILE *fp )
- int getchar( void )
- char *gets( char *s )
- int getw( FILE *fp )
- void perror( const char *string )
-
int printf( const char
*format [, arg1, arg2, ...] )
- int putc( int c, FILE *fp )
- int putchar( char c )
- int puts( const char *string )
- int putw( int n, FILE *fp )
- int remove( char *filename )
- int rename( const char *oldf, const char *newf )
- void rewind( FILE *fp )
- int rmtmp( void )
-
int scanf( const char *format,
arg1, arg2, ... )
- void setbuf( FILE *stream, char *buf )
-
int setvbuf( FILE *stream, char *buf, int type, size_t size )
-
int sprintf( char *s, const char *format [, arg1, arg2, ...] )
-
int sscanf( const char *s, const char *format, arg1, arg2, ... )
- char *tempnam( char *dir, char *prefix )
- int ungetc( int c, FILE *fp )
-
int vfprintf( FILE *stream, const char *format, va_list param )
-
int vfscanf( FILE *stream, const char *format, va_list argp )
- int vprintf( const char *format, va_list param )
- int vscanf( const char *format, va_list argp )
-
int vsprintf( char *string, const char *format, va_list param )
-
int
vsscanf( const char *string, const char *format, va_list argp )
Console Input/Output (conio.h)
Other Input/Output
-
int absread( int drive, int count, int start, void *buffer )
-
int abswrite( int drive, int sectors, int start, void *buffer )
- int access( const char *filename, int amode )
- int _creat( const char *fname, int attr )
- int creattemp( char *filename, int attr )
- int _chmod( const char *filename, int func [,int attrib] )
- int chmod( const char *filename, int permiss)
- int _close( int fh )
- int close( int fh )
- int creat( const char *filename, int permis )
- int creatnew( const char *fname, int attr )
-
unsigned creatnew( const char *fname, unsigned attr, int fh )
- int dup( int handle )
- int dup2( int oldhandle, int newhandle )
- int eof( int handle )
- long filelength( int handle )
- int ioctl( int handle, int cmd [, void *argdx, int argcx] )
- int isatty( int handle )
- int lock( int handle, long offset, long length )
- int locking( int handle, int mode, long nbytes )
- long lseek( int handle, long offset, int mode )
- int _open( const char *path, int access )
- int open( const char *path, int access [, unsigned permis] )
- int _read( int handle, void *buf, int size )
- int read( int handle, char *buf, int size )
- int setmode( int handle, int mode )
-
int sopen( const char *path, int access, int shflag, int mode )
- long tell( int handle )
- int umask( int permission )
- int unlock( int handle, long offset, long length )
- int _write( int handle, char *buf, int count )
- int write( int handle, char *buf, int count )
Filesystem operation
- int chdir( const char *path )
-
void
fnmerge( char *path, const char *drive, const char *dir, const
char *name, const char *ext)
-
void fnsplit( const char *path, char *drive, char *dir, char
*name, char *ext)
- int fstat( int handle, struct stat *buff )
- int getcurdir( int drive, char *direc )
- char *getcwd( char *buf, int n )
- int mkdir( const char *pathname )
- char *mktemp( char *template )
- int rmdir( const char *path )
- char *searchpath( const char *filename )
- int setdisk( int drive )
- int stat( char *pathname, struct stat *buff )
Memory allocation
- void *alloca( size_t size )
-
void _based(void) *_bexpand( _segment seg, void _based(void)
*block, size_t size )
- void _bfree( _segment seg, void _based(void) *block )
- int _bheapchk( _segment seg )
- int _bheapset( _segment seg, unsigned fill )
- int _bheapwalk( _segment seg, struct _heapinfo *entry )
- void _based(void) *_bmalloc( _segment seg, size_t size )
- size_t _bmsize( _segment seg, void _based( void ) *block )
- int brk( void *endds )
- unsigned coreleft( void )
- unsigned long coreleft( void )
- void *_expand( void *block, size_t size )
-
void far
*farcalloc( unsigned long nunits, unsigned long units )
- unsigned long farcoreleft( void )
- void farfree( void far *block )
-
void far *farrealloc( void far *block, unsigned long newsize )
- void far *_fexpand( void far *block, size_t size )
- int _fheapchk( void )
- int _fheapset( unsigned fill )
- int _fheapwalk( struct _heapinfo *entry )
- void far *_fmalloc( size_t size )
- size_t _fmsize( void far *block )
- void _ffree( void far *block )
- void free( void *pseg )
- unsigned _freect( size_t size )
- void huge *halloc( long num, size_t size )
- int _heapchk( void )
- int _heapset( unsigned fill )
- int _heapwalk( struct _heapinfo *entry )
- void hfree( void huge *block )
- size_t _memavl( void )
- size_t _msize( void *block )
- void near *_nexpand( void near *block, size_t size )
- void _nfree( void near *block )
- int _nheapchk( void )
- int _nheapset( unsigned fill )
- int _nheapwalk( struct _heapinfo *entry )
- void near *_nmalloc( size_t size )
- size_t _nmsize( void far *block )
- void *sbrk( int incr )
- size_t stackavail( void )
Graphics mode functions
- void far _clearscreen( short target )
- short far _displaycursor( short flag )
-
short _ellipse( short ctl, short x1, short y1, short x2, short
y2 )
-
short _ellipse_w( short ctl, double wx1, double wy1, double wx2,
double wy2 )
-
short far _ellipse_wxy( short ctl, struct _wxycoord far *pwxy1,
struct _wxycoord far *pwxy2 )
- short far _floodfill( short x, short y, short bcolor )
-
short far _floodfill_w( double wx, double wy, short bcolor )
- short far _getcolor( void )
-
flagType GetColor( LINE line, la *colorlist, PFILE pFile )
- struct xycoord far _getcurrentposition( void )
-
struct _wxycoord far _getcurrentposition_w( void )
-
unsigned char far *_getfillmask( unsigned char far *mask )
-
void far
_getimage( short x1, short y1, short x2, short y2, char huge
*image )
-
void far
_getimage_w( double wx1, double wy1, double wx2, double wy2,
char huge *image )
-
void far
_getimage_wxy( struct _wxycoord far *pwxy1, struct _wxycoord
far *pwxy2,char huge *image )
-
void far
getimage( int left, int top, int right, int bottom, void far
*bitmap )
- unsigned short far_getlinestyle( void )
- struct xycoord far _getlogcoord( short x, short y )
- struct xycoord far _getphyscoord( short x, short y )
- short far _getpixel( short x, short y )
- short far _getpixel_w( double wx, double wy )
- short far _gettextcolor( void )
- struct rccoord far _gettextposition( void )
-
struct videoconfig far
*_getvideoconfig( struct videoconfig far *config )
-
unsigned far
imagesize( int left, int top, int right, int bottom )
- short far _lineto( short x, short y )
- short far _lineto_w( double wx, double wy )
- struct xycoord far _moveto( short x, short y )
- struct _wxycoord far _moveto_w( double wx, double wy )
- void far_outtext( unsigned char far *text )
-
short
_pie( short control, short x1, short y1, short x2, short y2, short
x3, short y3, short x4, short y4 )
-
short far
_pie_wxy( short ctl, struct _wxycoord far *pwxy1, struct _wxycoord
far *pwxy2, struct _wxycoord far *pwxy3, struct _wxycoord far *pwxy4 )
- void PutColor( LINE line, la *colorlist, PFILE pFile )
-
void
_putimage( short x, short y, char huge *image, short action )
-
void far
_putimage_w( double wx, double wy, char huge *image, short
action )
-
void far
putimage( int left, int top, void far *bitmap, int option )
-
short
_rectangle( short ctl, short x1, short y1, short x2, short y2
)
-
short far
_rectangle_w( short control, double wx1, double wy1, double
wx2, double wy2 )
-
short far
_rectangle_wxy( short control, struct _wxycoord far *pwxy1,
struct _wxycoord far *pwxy2 )
- short far _remapallpalette( long far *colors )
-
long far _remappalette( short pixnum, long color )
- short far _selectpalette( short palette )
- short far _setactivepage( short page )
- long far _setbkcolor( long color )
-
void far
_setcliprgn( short x1, short y1, short x2, short y2 )
- short far _setcolor( short color )
- void far _setfillmask( unsigned char far *mask )
- short far _setfont( unsigned char far *options )
- void far _setlinestyle( unsigned short mask )
- struct xycoord far _setlogorg( short x, short y )
- short far _setpixel( short x, short y )
- short far _setpixel_w( double wx, double wy )
- short far _settextcolor( short color )
-
struct rccoord far
_settextposition( short row, short column )
-
void far
_settextwindow( short r1, short c1, short r2, short c2 )
- short far _setvideomode( short mode )
-
void far
_setviewport( short x1, short y1, short x2, short y2 )
- short far _setvisualpage( short page )
- short far _wrapon( short wrap )
Standard library (stdlib.h)
- void abort( void )
- int abs( int n )
- int atexit( void func )
- double atof( const char *s )
- int atoi( const char *s )
- long atol( const char *s )
-
void
*bsearch( void *key, void *base, int nelem, int width, int (*fcmp
)())
- void *calloc( unsigned count, unsigned sizeeach )
- struct _div_t div( int numer, int denom )
- struct _ldiv_t ldiv( long int numer, long int denom )
- char *ecvt( double value, int ndigit, int *decpt, int *sign )
- void exit( int completioncode )
- char *fcvt( double value, int ndigit, int *decpt, int *sign )
- char *gcvt( double value, int ndigit, char *buf )
- char *getenv( const char *envvar )
- char *itoa( int value, char *string, int radix )
- long labs( long n )
- void *malloc( unsigned size )
-
void
_makepath( char *path, char *drive, char *dir, char *fname,
char *ext )
-
void
*lfind(void *key,void *base,int *nelem,int width,int (*fcmp)())
- unsigned long _lrotl( unsigned long value, int n )
- unsigned long _lrotr( unsigned long value, int n )
-
void
*lsearch(void *key,void *base,int *nelem,int width,int (*fcmp)())
- char *ltoa( long value, char *string, int radix )
- onexit_t onexit( onexit_t func )
- int putenv( const char *envvar )
-
void
qsort( void *array, size_t n_elem, size_t elem_size, int
(*fcmp)(const void *, const void *) )
- int rand( void )
- void *realloc( void *pseg, unsigned size )
- unsigned _rotl( unsigned value, int shift )
- unsigned _rotr( unsigned value, int shift )
- void _searchenv( char *fname, char *var, char *path )
-
void
_splitpath( char *path, char *drive, char *dir, char *fname,
char *ext )
- void srand( unsigned seed )
- char *ultoa( unsigned long value, char *string, int radix )
Process management and IPC
-
int execl( char *pathname, char *arg0, char *arg1, ..., NULL )
-
int execle( char *pathname, char *arg0, char *arg1, ..., NULL,
char *envp[] )
-
int execlp( char *pathname, char *arg0, char *arg1, ..., NULL )
-
int execlpe( char *pathname, char *arg0, char *arg1, ..., NULL,
char *envp[] )
- int execv( char *pathname, *arg, NULL )
- int execve( char *pathname, *arg, NULL, char *envp[] )
- int execvp( char *pathname, *arg, NULL )
- int execvpe( char *pathname, *arg, NULL, char *envp[] )
- void _exit( int completioncode )
- int gsignal( int sig )
- int getpid( void )
-
int spawnl( int mode, char *path, char *arg0, char *arg1, ..., NULL
)
-
int spawnle( int mode, char *path, char *arg0, char *arg1, ...,
NULL, char *envp[] )
-
int spawnlp( int mode, char *path, char *arg0, char *arg1, ...,
NULL )
-
int spawnlpe( int mode, char *path, char *arg0, char *arg1, ...,
NULL, char *envp[] )
- int spawnv( int mode, char *path, char *argv )
-
int spawnve( int mode, char *path, char *argv, char *envp[] )
- int spawnvp( int mode, char *path, char *argv )
-
int spawnvpe( int mode, char *path, char *argv, char *envp[] )
- int (*ssignal( int sig, int (*action))) (void)
- void swab( char *src, char *dest, int nbytes )
- int system( const char *command )
- int raise( int sig )
Time and date functions
String and memory functions
You may also check the topic providing a summary of the
memory manipulation functions and
string manipulation functions.
-
void *memccpy(void *dest, const void *src, int ch, size_t n)
- void *memchr( const void *s, int ch, size_t n )
- int memcmp( const void *s1, const void *s2, size_t n )
- void *memcpy( void *dest, const void *src, size_t n )
- int memicmp( const void *s1, const void *s2, size_t n )
- void *memmove( void *dest, const void *src, size_t n )
- void *memset( void *s, int ch, size_t n )
-
void
movedata( unsigned segsrc, unsigned offsrc, unsigned segdest,
unsigned offdest, size_t n )
- void movmem( void *src, void *dest, unsigned len )
- void setmem( void *addr, int len, char value )
- char *stpcpy( char *dest, const char *src )
- char *strcat( char *dest, const char *src )
- char *strchr( const char *str, int c )
- int strcmp( const char *str1, const char *str2 )
- char *strcpy( char *dest, const char *src )
- size_t strcspn( const char *str1, const char *str2 )
- char *strdup( const char *str )
- char *_strerror( char *string )
- char *strerror( char *str )
- int stricmp( const char *str1, const char *str2 )
- size_t strlen( const char *str )
- char *strlwr( char *str )
-
char *strncat( char *dest, const char *src, size_t maxlen )
-
int strncmp( const char *str1, const char *str2, size_t maxlen )
-
char *strncpy( char *dest, const char *src, size_t maxlen )
-
int
strnicmp( const char *str1, const char *str2, size_t maxlen )
- char *strnset( char *str, int ch, size_t n )
- char *strpbrk( const char *str1, const char *str2 )
- char *strrchr( const char *str, int c )
- char *strrev( char *str )
- char *strset( char *str, int ch )
- size_t strspn( const char *str1, const char *str2 )
- char *strstr( const char *anchor, const char *testpattern )
- double strtod( const char *str, char **endptr )
- char *strtok( char *str1, const char *str2 )
- long strtol( const char *str, char **endptr, int base )
-
unsigned long strtoul( const char *s, char **endptr, int radix )
- char *strupr( char *str )
Math functions (math.h)
- double acos( double x )
- double asin( double x )
- double atan( double x )
- double tan( double y, double x )
- double cabs( struct complex z )
- double ceil( double x )
- double cos( double x )
- double cosh( double x )
- int dieeetomsbin( double *srcdbl, double *dstdbl )
- int dmsbintoieee( double *srcdbl, double *dstdbl )
- double exp( double x )
- double fabs( double x )
- int fieeetomsbin( float *srcflt, float *dstflt )
- double floor( double x )
- int fmsbintoieee( float *srcflt, float *dstflt )
- double fmod( double x, double y )
- double frexp( double value, int eptr )
- double hypot( double x, double y )
- double ldexp( double value, int exp )
- double log( double x )
- double log10( double x )
-
double
_matherr( _mexcep why, char *fun, double *arg1p, double *arg2p,
double retv )
- int matherr( struct exception *e )
- double modf( double value, double *iptr )
- double poly( double x, int n, double coeff[] )
- double pow( double x, double y )
- double pow10( double x )
- double sin( double x )
- double sinh( double x )
- double sqrt( double x )
- double tan( double x )
- double tanh( double x )
Assertion library (assert.h)
Type utilities (ctype.h)