Function name: ECVT function: convert a floating point number into a string usage: char ECVT (Double Value, Int NDIGIT, INT * DECPT, INT * SIGN);
#include
#include
#include
INT main (void) {char * string; double value; int DEC, SIGN; INT NDIG = 10;
CLRSCR (); value = 9.876; string = ECVT (Value, NDIG, & DEC, & SIGN); Printf ("String =% S Dec =% D / Sign =% D / N", String, DEC, SIGN);
Value = -123.45; ndig = 15; String = ECVT (Value, NDIG, & DEC, & SIGN); Printf ("String =% S Dec =% D Sign =% D / N", String, DEC, SIGN);
Value = 0.6789E5; / * scientific notation * / ndig = 5; string = ECVT (Value, NDIG, & DEC, & SIGN); Printf ("String =% s Dec =% D / Sign =% D / N", String, Dec, sign);
Return 0;}
Function Name: Ellipse Features: Draw an Elliptical Usage: Void Far Ellipse (int X, int y, int stangle, int endangle, int xradius, int yradius);
#include
#include
#include
#include
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; int = 0, endangle = 360; int Xradius = 100, yradius = 50;
/ * Initialize Graphics, Local Variables * / Initgraph (& gdriver, & gmode, "");
/ * read results = graphresult (); if (error (error) / * an error opcurred * / {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); / * Terminate with an error code * /}
MIDX = getmaxx () / 2; Midy = getMaxy () / 2; setColor (GetMaxColor ());
/ * Draw Ellipse * / Ellipse (MIDX, Midy, Stangle, Endangle, XRADIUS, YRADIUS)
/ * CLOAN UP * / GETCH (); closegraph (); return 0;}
Function Name: Enable Features: Open Hardware Interrupt Usage: Void Enable (Void);
/ * ** Note: this is an interrupt service routine. You can not compile this program with get an executable file which will operate Correctly. * / # Include
#include
#include
/ * The clock tick interface interrupt * / #define INTR 0x1c
Void Interrupt (* OldHandler) (Void);
INT count = 0;
void interrupt handler (void) {/ * disable interrupts during the handling of the interrupt * / disable (); / * increase the global counter * / count ; / * re enable interrupts at the end of the handler * / enable (); / * Call the old routine * / oldhandler ();}
Int main (void) {/ * save the old interrupt vector * / oldhandler = getVect (INTR);
/ * Install The New Interrupt Handler * / setVect (Intr, Handler);
/ * loop untric the counter Exceeds 20 * / while (count <20) Printf ("count IS% d / n", count);
/ * RESET The Old Interrupt Handler * / setVect (INTR, OLDHANDLER);
Return 0;}
Function name: EOF function: Detection file end usage: int EOF (int * handle);
#include
#include
#include
#include
#include
INT main (void) {Int Handle; char msg [] = "this is a test"; char ch;
/ * CREATE A file * / handle = Open ("Dummy.fil", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
/ * Write Some Data To The File * / Write (Handle, MSG, Strlen (MSG));
/ * Seek to the beginning of the file * / lseek (handle, 0l, seek_set);
/ * READS Chars from The File Until Hit EOF * / DO {Read (Handle, & Ch, 1); Printf ("% C", CH);} While (! EOF (Handle));
Close (Handle); Return 0;
Function Name: EXEC ... Function: Functions to load and run other programs: int execl (char * pathname, char * arg0, arg1, ..., argn, null); int execle (char * pathname, char * Arg0, Arg1, ..., Argn, NULL, CHAR * ENVP []; int execlp (char * pathname, char * arg0, arg1, .., null); int execple (char * pathname, char * arg0, arg1 , ..., NULL, CHAR * ENVP []); int execv (Char * pathname, char * argv []); int execve (char * pathname, char * argv [], char * envp []); int execvp (char * pathname, char * argv []); int execvpe (char * pathname, char * argv [], char * envp []); program case: / * execv esample * / #include
#include
#include
Void Main (int Argc, char * argv []) {INT i;
Printf ("Command Line Arguments: / N"); for (i = 0; I
Printf ("[% 2D]:% S / N", I, Argv [I]);
Printf ("About to EXEC Child With Arg1 Arg2 ... / N"); Execv ("Child.exe", Argv);
Perror ("Exec Error");
Exit (1);
Function Name: EXIT Function: Termination Program Us: Void Exit; Procedure:
#include
#include
#include
INT main (void) {int stat;
Printf ("Enter Either 1 or 2 / N"); status = getch (); / * sets dos errorlevel * / exit (status - '0');
/ * NOTE: this line is never reached * / return 0;}
Function Name: EXP Function: Index Function Usage: Double Exp (Double X);
#include
#include
INT main (void) {Double Result; Double X = 4.0;
Result = exp (x); Printf ("'e' raised to the power / of% LF (E ^% LF) =% LF / N", X, X, Result)
Return 0;}
Function Name: DELAY Energy: Pause the execution of the program for a period of time (milliseconds): void delay (unsigned milliseconds); example: / * Emits a 440-hz Tone for 500 MilliseConds * / #include
INT main (void) {Sound (440); DELAY (500); noid ();
Return 0;}
Function Name: Delline Features: Remove a line of use in the text window: Void Delline (Void);
#include
INT main (void) {clrs CL (); CPrintf ("THE FUNCTION DELLETES / THE LINE Containing THE / R / N"); CPRINTF ("" Cursor and Moves All Lines / Below It One Line Up./R/N ") CPrintf ("Delline Operates forin The / Currently Active Text / R / N"); CPrintf ("Window. Press any key to / continue..."); gotoxy (1, 2); / * Move the cursor to the the SECOND LINE and FIRST Column * / getch (); Delline (); getch ();
Return 0;}
Function Name: DetectGraph Function: Determines Graphics Drivers and Mode Law by Detection: Void Far DetectGraph (Int Far * GraphDriver, Int Far * graphmode);
#include
#include
#include
#include
/ * name of the various cards supported * / char * DNAME [] = {"Requests Detection", "A CGA", "AN MCGA", "AN EGA", "A 64K EGA", "A Monochrome EGA", " AN IBM 8514, "A Hercules Monochrome", "AT & T 6300 PC", "A VGA", "AN IBM 3270 PC"}
INT main (void) {/ * returns detected hardware info. * / INT GDRIVER, GMODE, ERRORCODE
/ * Detect graphics hardware available * / detectgraph (& gdriver, & gmode);
/ * Read Result of detectgraph call * / errorcode = graphresult (); if (ErrorCode! = GROK) / * An error ire {printf ("Graphics Error:% S / N", / GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * terminate with an error code * /}
/ * display the information detected * / clrs (); Printf ("You Have% S Video Display / Card./N", DNAME [GDRIVER]); Printf ("Press Any Key to Halt:"); getCH (); Return 0;}
Function Name: DIFFTIME function: calculate time difference between two moments: Double DiffTime (Time_t Time2, Time_t Time1);
#include
#include
#include
#include
Int main (void) {TIME_T FIRST, SECOND
CLRSCR (); first = time (null); / * gets system time * / delay (2000); / * Waits 2 secs * / second = time (null); / * gets system time again * / printf ("The Difference" IS:% F / Seconds / N ", DIFFTIME (SECOND, FIRST); getCH ();
Return 0;}
Function Name: Disable Features: Shield Interrupt Usage: Void Disable (Void);
/ *** Note: this is an interrupt service routine. You cannot Compile This Program with test stack overflow turned on and get an executable file what operates correctly. * /
#include
#include
#include
#define INTR 0x1C / * The Clock Tick Interrupt * /
Void Interrupt (* OldHandler) (Void);
INT count = 0;
void interrupt handler (void) {/ * disable interrupts during the handling of the interrupt * / disable (); / * increase the global counter * / count ; / * reenable interrupts at the end of the handler * / enable (); / * Call the old routine * / oldhandler ();
Int main (void) {/ * save the old interrupt vector * / oldhandler = getVect (INTR);
/ * Install The New Interrupt Handler * / setVect (Intr, Handler);
/ * loop untric the counter Exceeds 20 * / while (count <20) Printf ("count IS% d / n", count);
/ * RESET The Old Interrupt Handler * / setVect (INTR, OLDHANDLER);
Return 0;}
Function Name: DIV function: Erase two integers, return business and expensive usage: DIV_T (int Number, int Denom);
#include
#include
DIV_T X;
INT main (void) {x = div (10, 3); Printf ("10 Div 3 =% D Remainder D / N", X.quot, X.Rem);
Return 0;}
Function Name: DOSEXTERR Function: Get Extension DOS Error Information: Int DosexTerr (Struct Doserr * DBLKP);
#include
#include
INT main (void) {file * fp; struct doserror info;
FP = FOPEN ("PERROR.DAT", "R"); if (! fp) PERROR ("Unable to open file forreading"; dosexterr (& info);
Printf ("Extended DOS Error / Information: / N"); Printf ("Extended Error: /% D / N", Info.exTerror); Printf ("Class: /% X / N", Info.class; Printf ("ACTION: /% x / n", info.action; Printf ("Error Locus: /% x / n", info.locus); Return 0;}
Function Name: Dostounix Features: Conversion Date and Time for UNIX Time Format: Long Dostounix (Struct Date * Dateptr, Struct Time * TimePtr);
#include
#include
#include
#include
INT main (void) {TIME_T T; Struct Time D_TIME; Struct Date D_Date; StructTM * local;
GetDate (& D_DATE); GetTime (& D_TIME);
T = dostounix (& D_Date, & D_TIME); local = localtime (& T); Printf ("Time and Date: S / N", / asctime (local));
Return 0;}
Function Name: DrawPoly Features: Draw Polygon Usage: Void Far DrawPoly (Int Numpoints, Int Far * Polypoints);
#include
#include
#include
#include
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int maxx, maxy;
/ * OUR POLYGON ARRAY * / INT POLY [10];
/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");
/ * read results = graphResult (); if (errorcode! = grok) / * an error ocurred * / {printf ("graphics error:% s / n", / grapherrormsg (errorcode)); Printf "Press Any Key to Halt:"); getch (); / * Terminate with an error code * / exit (1);
Maxx = getmaxx (); maxy = getMaxy ();
POLY [0] = 20; / * 1st Vertext * / Poly [1] = MAXY / 2;
Poly [2] = Maxx - 20; / * 2nd * / poly [3] = 20;
Poly [4] = Maxx - 50; / * 3rd * / poly [5] = MAXY - 20;
Poly [6] = Maxx / 2; / * 4th * / poly [7] = maxy / 2; / * DrawPoly Doesn't Automatically Close The Polygon, So We Close It. * / Poly [8] = Poly [0] Poly [9] = poly [1]; / * Draw the polygon * / drawpoly (5, poly);
/ * CLOAN UP * / GETCH (); closegraph (); return 0;}
Function name: DUP function: copy a file handle usage: int dup (int Handle);
#include
#include
#include
#include
Void Flush (file * stream);
INT main (void) {file * fp; char msg [] = "this is a test";
/ * CREATE A file * / fp = fopen ("Dummy.fil", "W");
/ * Write Some Data to the file * / fwrite (MSG, Strlen (MSG), 1, FP);
CLRSCR (); Printf ("Press any key to flush / dummy.fil:"); getCH ();
/ * Flush the data to dummy.fil without closing it * / flush (fp);
Printf ("/ Nfile Was flushed, Press any / key to quit:"); getCh (); return 0;}
Void Flush (file * stream) {int duphandle;
/ * Flush TC's Internal Buffer * / fflush (stream);
/ * Make a duplicate file hand is * / duphandle = DUP (Fileno (stream));
/ * Close The duplicate handle to flush the dos buffer * / close (duphandle);
Function Name: DUP2 Function: Copy File Handle Usage: Int Dup2 (INT OLDHANDLE, INT NewHandle);
#include
#include
#include
#include
Int main (void) {#define stdout 1
INT NUL, OLDSTDOUT; Char Msg [] = "this is a test";
/ * CREATE A file * / NUL = Open ("Dummy.fil", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
/ * Create a duplicate handle for standard output * / oldstdout = dup (STDOUT); / * redirect standard output to DUMMY.FIL by duplicating the file handle onto the file handle for standard output * / dup2 (nul, STDOUT).;
/ * Close The Handle for Dummy.fil * / Close (NUL);
/ * Will Be Redirected Into Dummy.fil * / Write (stdout, msg, strlen (msg));
/ * restore Original Standard Output Handle * / DUP2 (OldStdout, Stdout); / * Close Duplicate Handle for Stdout * / Close (OldStdout);
Return 0;}
Function name: CABS function: calculation of absolute value usage: Double Cabs (Struct Complex Z); program: #include
#include
INT main (void) {struct complex z; double val; zx = 2.0; zy = 1.0; Val = Cabs (z); Printf ("The Absolute value of% .2LFI% .2LFJ IS% .2LF", ZX, ZY , RETURN 0;} function name: Calloc function: Assigning master memory usage: void * calloc (size_t nlem, size_t elsize); program case: #include
#include
INT main (void) {char * str = null; / * allocate memory for string * / str = Calloc (10, sizeof (char)); / * Copy "Hello" Into String * / STRCPY (STR, "Hello") ; / * Display string * / printf ("String IS% S / N", STR); / * free memory * / free (str); Return 0;} function name: CEIL function: upwards: Double CEIL Double X); example: #include
#include
INT main (void) {Double Number = 123.54; Double Down, Up; DOWN = Floor (Number); Up = CEIL (Number); Printf ("Original Number% 5.2LF / N", Number); Printf ("Number Rounded DOWN% 5.2LF / N ", DOWN); Printf (" Number Rounded Up% 5.2LF / N ", UP); Return 0;} Function Name: CGETS Function: From Console Read Characters: Char * CGETS (Char * STR); example: #include
#include
INT main (void) {charffer [83]; char * p; / * there's space for 80 character * / buffer [0] = 81; Printf ("Input Some Chars:"); P = CGETS Buffer; Printf ("/ Ncgets Read% D character: /"% s / "/ n", buffer [1], p); Printf ("The Returned Pointer IS% P, Buffer [0] IS AT% P / n ", p, & buffer; / * Leave room for 5 character * / buffer [0] = 6; Printf (" Input Some Chars: "); P = cgets (buffer); Printf (" / ncgets Read% D characters: / "% s /" / n ", buffer [1], p); Printf (" The Returned Pointer IS% P, Buffer [0] IS AT% P / N ", P, & Buffer; Return 0;} function name: chDIR function: Change work directory usage: int chd char * path; program: # includ # include
#include
CHAR OLD_DIR [Maxdir]; char new_dir [maxdir]; int main (void) {if (GetCurdir ("getCurDir ()"); exit (1);} printf ("Current Directory IS: //% S / N ", OLD_DIR); if (chDIR (" // ")) {Perror (" chDIR () "); exit (1);} if (getCurdir (0, new_dir)) {PERROR (" GetCurDir () "); exit (1);" Current Directory IS NOW: //% S / N ", New_DIR); Printf (" / NChanging Back to Orignal Directory: //% S / N ", Old_Dir ); if (chd_dir)) {PERROR ("chdir ()"); exit (1);} return 0;} function name: _chmod, chmod function: change file access method usage: int CHMOD (const char * FileName, int permiss; program: #include
#include
#include
void make_read_only (char * filename); int main (void) {make_read_only ( "NOTEXIST.FIL"); make_read_only ( "MYFILE.FIL"); return 0;} void make_read_only (char * filename) {int stat; stat = chmod (filename, s_iread); if (stat) printf ("couldn't make% s ied-only / n", filename); Else Printf ("MADE% s ied-only / n", filename);} function name: Chsize function: change file size usage: int Chsize (int Handle, long size); program: # includ # include
#include
INT main (void) {Int Handle; Char BUF [11] = "0123456789"; / * Create text file containing 10 bytes * / handle = open ("Dummy.fil", O_Creat); Write (Handle, BUF, Strlen BUF); / * Truncate the file to 5 bytes in size * / chsize (Handle, 5); / * Close the file * / close (Handle); Return 0;} function name: Circle function: at a given radius (x, y) for rounded circular use: Void Far Circle (int X, int y, int radius); example: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; int radius = 100; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, "") / * Read results = graphResult (); if (ErrorCode! = GROK) / * an Error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf "Press Any Key to Halt:"); getCH (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; setColor (getmaxcolor () ); / * Draw the circle * / circle (MIDX, MIDY, RADIUS); / * Clean up * / getch (); closegraph (); return 0;} function name: ClearDevice function: Clear graphics screen usage: Void Far ClearDevice (void); example: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result OF INITIALIZATION * / ErrorCode = graphresult (); if (ErrorCode! = GROK) / * an Error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key To Halt: "); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; setColor (getMaxcolor ()); / * for centering screen messages * / settextjustify (CENTER_TEXT, CENTER_TEXT); / * output a message to the screen * / outtextxy (midx, midy, "press any key to clear the screen:"); / * wait for a key * / getch ( ); / * clear the screen * / clearden (); / * Output iTher Message * / OutTextxy (Midx, Midy, "Press any key to quit:"); / * Clean up * / getch (); closegraph (); RETURN 0;} function name: Clearerr function: Reset error flag usage: Void Clearerr (file * stream); program: #includeint main (void) {file * fp; char CH; / * Open a file for Writing * / fp = fopen ("dummy.fil", "w"); / * force an error condition by attempting to read * / ch = fgetc (fp); printf ("% C / N ", CH); if (FERROR (FP)) {/ * display an error message * / printf (" error reading from dummy.fil / n "); / * reset the error and eof indeicators * / clearrr (fp); } fclose (fp); Return 0;} function name: ClearViewPort function: Clear graphics area usage: Void Far ClearViewPort (Void); program case: #include
#include
#include
#include
#define CLIP_ON 1 / * activates clipping in viewport * / int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int ht; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, "" "; / * read result = graphresult (); if (erroorcode! = grok) / * an error occrred * / {printf (" Graphics Error:% S / N ", Grapherror (ErrorCode ))); Printf ("Press Any Key to Halt:"); getCh (); exit (1); / * Terminate with an error code * /} setColor (getMaxColor ()); ht = textheight ("w"); / * Message in default full-screen viewport * / Outtextxy (0, 0, "* <- (0, 0) in default viewport"); / * Create A Smaller ViewPort * / setViewPort (50, 50, getmaxx () -50, getmaxy () - 50, clip_on); / * Display Some Messages * / Outtextxy (0, 0, "* <- (0, 0) in smaller viewport"); Outtextxy (0, 2 * ht, " Press any key to clear viewport: "); / * Wait for a key * / getch (); / * clear the viewport * / clearviewport (); / * Output Another Message * / Outtextxy (0, 0," Press Any Ke y to quit: "); / * clean up * / getch (); closegraph (); return 0;} function name: _close, close function: Close file handle method: int close (int Handle); program: #include #include
#include
#include
Main () {Int Handle; Char BUF [11] = "0123456789"; / * Create a file containing 10 bytes * / hand = Open ("new.fil", o_creat); if (handle> -1) {WRITE Handle, BUF, Strlen (Buf); / * close the file * / close (Handle);} Else {Printf ("Error Opening File / N");} Return 0;} Function Name: Clock function: Determine the processor Time Usage: Clock_t Clock (Void); Procedure: #include
#include
#include
INT main (void) {clock_t start, end; start = clock (); delay (2000); end = clock (); Printf ("Time Was:% F / N", (end - start) / clk_tck); Return 0;} function name: closedgraph function: Close graphic system usage: void far closegraph (void); program case: # includ # include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int x, y; / * initialize graphics mode * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); if (ErrorCode! = GROK) / * An error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt: "); getCH (); exit (1); / * Terminate with an error code * /} x = getmaxx () / 2; y = getMaxy () / 2; / * Output a message * / settextjustify (center_text, center_text ); OutTextxy (x, y, "Press A Key to Close The Graphics System:"); / * Wait for a key * / getch (); / * closes down the graphics system * / closegraph (); Printf ("WE 'Re now back in text mode./N "); PrintF (" Press Any Key to Halt: "); getch (); return 0;} function name: Clreol function: Clear character in the text window to row usage: void Clreol (void); example: #include
INT main (void) {clrs (); CPrintf ("The Function Clreol Clears All Characters from THE / R / N"); CPrintf ("Cursor Position To The End of The Line With"); CPRINTF "Current Text Window, without Moving The Cursor./R/N"); CPRINTF ("Press any key to pay"); gotoxy (14, 4); getCh (); clreol (); getch (); Return 0;} function name: CLRSCR function: Clear text mode window usage: Void ClrsCr (void); program case: #include
INT main (void) {INT I; CLRSCR (); for (i = 0; i <20; i ) CPrintf ("% d / r / n", i); cprintf ("/ r / npress any key to clear "); getch (); clrs CLSCR (); CPRINTF (" THE Screen Has Been Cleared! "); getch (); return 0;} function name: Coreleft function: Return unused size usage: unsigned Coreleft (Void );
INT main (void) {Printf ("The Difference Between The Highest Allocated Block and / N"); Printf ("Top of the Heap IS:% Lu Bytes / N", (Unsigned Long) Coreleft ()); Return 0 } Function name: COS function: cosine function usage: double cos (double x); program case: #include
#include
INT main (void) {Double Result; double x = 0.5; Result = COS (X); Printf ("The cosine of% LF IS% LF / N", X, Result); Return 0;} function name: COSH function : Double Cosine Function Usage: DLUBLE COSH (Double X); Certificate: #include
#include
INT main (void) {Double Result; Double X = 0.5; Result = COSH (X); Printf ("The Hyperboic Cosine OF% LF IS% LF / N", X, Result); Return 0;} function name: Country Function: Returns information about the country: Struct Country * Country (int COUNTRYCODE, STRUCTRY * Country; program: #include
#include
#define USA 0 int main (void) {struct country country_info; country (USA, & Country_info); Printf ("" The currency symbol for the USA IS:% S / N ", country_info.co_curr); Return 0;} function name: CPRINTF function: send formatted output to screen usage: int CPrintf (const char * format [, argument, ...]); program case: #include
INT main (void) {/ * clear the screen * / clrs (); / * Create a text window * / window (10, 10, 80, 25); / * Output Some text in the window * / cprintf ("Hello World / r / n "); / * Wait for a key * / getch (); return 0;} function name: CPUTS function: write characters to screen usage: void cputs (const char * string); program: #include
INT main (void) {/ * clear the screen * / clrs (); / * Create a text window * / window (10, 10, 80, 25); / * Output Some text in the window * / cputs ("this IS with the window / r / n "); / * Wait for a key * / getch (); return 0;} function name: _CREAT CREAT function: Create a new file or rewrite an existing file usage: int Creat (const char * filename, int permiss); program: # includ # include
#include
#include
INT main (void) {Int Handle; Char BUF [11] = "0123456789"; / * change the default file mode from text to binary * / _fmode = o_binary; / * create a binary file forreading and write * / handle = Creat ("Dummy.fil", S_IRead | S_IWRITE); / * WRITE 10 BYTES to THE FILE * / WRITE (HANDLE, BUF, STRLEN (BUF)); / * Close The File * / Close (Handle); Return 0; } Function Name: CreatNew Function: Create a new file usage: int Creatnew (const char * filename, int attrib); program: #include
#include
#include
#include
#include
INT main (void) {Int Handle; Char BUF [11] = "0123456789"; / * Attempt to create a file what doesn't already exist * / handle = CreatNew ("Dummy.fil", 0); if (Handle == -1) Printf ("Dummy.fil Already Exists./N"); Else {Printf ("Dummy.fil SuccessFully Created./N"); Write (Handle, BUF, Strlen (BUF)); Close (Handle );} RETURN 0;} function name: CreatTemp function: Create a new file or rewrite an existing file usage: int CreatTemp (const char * filename, int attrib); program case: #include
#include
#include
INT main (void) {int Handle; Char pathname [128]; strcpy (pathname, "//"); / * CREATE a unique file in the root directory * / handle = crettemp (pathname, 0); Printf ("% S Was The Unique File Created./N ", Pathname); Close (Handle); Return 0;} Function Name: CSCANF Function: Format Input from the console: int Cscanf (Char * format [, argument, .. .]); Example: #include
INT main (void) {char string [80]; / * clear the screen * / clrs (); / * prompt the user for input * / cprintf ("Enter a string with no spaces:"); / * read the input * / cscanf ("% s", string); / * Display What was read * / cprintf ("/ r / nthe string entered IS:% s", string); Return 0;} function name: CTIME function: Put date And time converted to a character string: char * ctime (const time_t * Time); program: # include # include
INT main (void) {TIME_T T; TIME (& T); Printf ("Today's Date:% S / N", CTIME (& T)); Return 0;} function name: CtrlBRK function: Set Ctrl-Break handler Usage: Void Ctrlbrk (* fptr) (void); program case: #include
#include
#define Abort 0 int C_break (void) {Printf ("Control-Break Pressed. Program Aborting ... / N"); return (abort);}}} {CtrlBRK (c_break); for (;;) {Printf ("Looping ... Press
To Quit: / N ");
}
Return 0;
}
Function name: BAR function: draw a two-dimensional bar graph usage: Void Far Bar (int LEFT, INT TOP, INT Right, INT BOTTOM);
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy, i; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * Read results = graphresult (); if (ErrorCode! = GROK) / * An error accurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt: "); getch (); exit (1); / * terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; / * loop through the fill pattern * / for (i = solid_fill; i
{
/ * SET the FILL STYLE * /
SetFillStyle (i, getmaxcolor ());
/ * DRAW THE BAR * / BAR (MIDX-50, MIDY-50, MIDX 50, MIDY 50); getch ();} / * clean up * / closegraph (); return 0;} function name: BAR3D function : Draw a three-dimensional bar3d method: Void Far Bar3d (int LEFT, INT TOP, INT RIGHT, INT BOTTOM, INT DEPTH, INT TOPFLAG);
#include
#include
INT main (void) {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; Int Midx, Midy, I; / * Initialize Graphics, Local Variables * / Initgraph (& gdriver, & gmode, ""); / * Read results = graphresult (); if (ErrorCode! = GROK) / * An error accurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt: "); getCH (); exit (1); / * terminate with error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; / * loop through the Fill Patterns * / For (i = Empty_Fill; i
{
/ * SET the FILL STYLE * /
SetFillStyle (i, getmaxcolor ());
/ * DRAW THE 3-D BAR * / BAR3D (MIDX-50, MIDY-50, MIDX 50, MIDY 50, 10, 1); getCh ();} / * clean up * / closegraph (); Return 0 (}) Function name: BDoS function: DOS system call usage: int bdos (int dosfun, unsigned dosdx, unsigned dosal); program case: #include
#include
/ * GET CURRENT Drive as 'a', 'b', ... * / char capital_drive (void) {char curdrive; / * get current disk as 0, 1, ... * / curdrive = bdos (0x19, 0 , 0); RETURN ('a' curdrive);} int main (void) {Printf ("THE CURRENT DRIVE IS% C: / N", current_drive ()); return 0;} function name: bdosptr function: DOS System call usage: int bdosptr (int dosfun, void * argument, unsigned dosal); program: #include
#include
#include
#include
#include
#include
#define buflen 80 int main (void) {charflen]; int Test; Printf ("Enter Full Pathname of A Directory); gets (buffer); test = bdosptr (0x3b, buffer, 0); if (TEST) {Printf ("DOS ERROR Message:% D / N", Errno); / * See Errno.h for error listings * / exit (1);} getcwd (buffer, buflen); Printf ("THE CURRENT DIRECTORY) IS:% S / N ", Buffer; Return 0;} function name: BIOSCOM function: Serial I / O communication usage: int Bioscom (int CMD, CHAR ABYTE, INT port); program case: # includ # include
#define com1 0 #define data_ready 0x100 #define true 1 #define false 0 #define settings (0x80 | 0x02 | 0x00 | 0x00) int main (void) {Int in, out, status, done = false; bioscom (0, Settings , COM1); CPRINTF ("... Bioscom [ESC] to EXIT ... / N"); While (! DONE) {status = bioscom (3, 0, COM1); if (status & data_ready) IF (((STATUS & DATA_READY) IF OUT = Bioscom (2, 0, COM1) & 0x7F)! = 0) PUTCH (OUT); if (kbhit ()) {IF ((in = getCH ()) == '/ x1b') DONE = true; bioscom (1, IN, COM1);}} Return 0;} function name: BiosDisk function: Soft hard disk I / O usage: int BiosDisk (int CMD, int DRIVE, INT Head, int TRACK, INT Sector Int nsects, void * buffer Application: #include
#include
INT main (void) {int result; char buffer [512]; Printf ("Testing to See if Drive A: is Ready / N"); Result = BiosDisk (4, 0, 0, 0, 0, 1, Buffer) Result & = 0x02; (Printf ("Drive A: Ready / N"): (Printf ("Drive A: NOTY / N"); return 0;} function name: Biosequip function: Check Equipment usage: int biosequip (void); example: #include
#include
INT main (void) {int result; char buffer [512]; Printf ("Testing to See if Drive A: is Ready / N"); Result = BiosDisk (4, 0, 0, 0, 0, 1, Buffer) Result & = 0x02; (Printf ("Drive A: Ready / N"): ("Drive A: NOTY / N")); Return 0;} function name: BIOSKEY function: Direct Use the BIOS service keyboard interface usage method: int Bioskey (int CMD); example: # include # include
#include
#define right 0x01 #define left 0x02 #define ctrl 0x04 #define alt 0x08 int main (void) {int key, modifier; / * function 1 returns 0 unsil a key is presssed * / while (Bioskey (1) == 0) ; / * function 0 returns the key = bioskey (0); / * Use function 2 to determine if Shift key used * / modifiers = bioskey (2); if (modifiers) {printf (" "); if (Modifiers & Right) PRINTF (" Right "); if (Modifiers & Left) Printf (" LEFT "); if (Modifiers & Ctrl) Printf (" Ctrl "); if (Modifier & Alt) Printf "Alt"); Printf ("]");} / * print out the character read * / if (isaly & 0xFF)) Printf ("'% c' / n", key); else printf ("% # 02x / n ", key); return 0;} function name: BiosMemory function: return storage block size usage: int BiosMemory (Void); program case: #include
#include
INT main (void) {int memory_size; memory_size = biosmemory (); / * returns value Up to 640k * / printf ("RAM SIZE =% DK / N", MEMORY_SIZE); RETURN 0;} function name: BiospRINT function: Direct Using a BIOS service printer I / O usage: int BiospRINT (int CMD, int Byte, int port); program case: #include
#include
#include
Int main (void) {#define status 2 / * Printer Status Command * / #Define portnum 0 / * Port Number for lpt1 * / int stat status, Abyte = 0; Printf ("please turn off your printer. Press Any Key to Continue / N "); getCH (); status = biosprint (status, abyte, portnum); if (status & 0x01) Printf (" Device Time Out./N "); if (Status & 0x08) Printf (" I / O Error./N "); if (status & 0x10) Printf (" SELECTED./N "); if (status & 0x20) Printf (" Out of Paper./N "); if (status & 0x40) Printf (" " Acknowledge./N "); if (status & 0x80) Printf (" not busy./N "); return 0;} function name: Biostime function: Read or set BIOS time usage: long biostime (int CMD, long newtime Application: # include # include
#include
#include
INT main (void) {long bios_time; clrs CRSCR (); CPrintf ("The Number of Clock Ticks Since Midnight IS: / R / N"); CPrintf ("The Number of Seconds Since Midnight IS: / R / N"); CPrintf ("THE NUMBER OF MINUTES SINCE MIDNIGHT IS: / R / N"); CPRINTF ("THE NUMBER OF Hours Since Midnight IS: / R / N"); CPrintf ("/ R / NPRESS ANY Key To Quit:") While (! kbhit ()) {BIOS_TIME = Biostime (0, 0L); gotoxy (50, 1); CPRINTF ("% lu", bios_time); gotoxy (50, 2); cprintf ("%. 4f", BIOS_TIME / CLK_TCK); Gotoxy (50, 3); CPRINTF ("%. 4F", BIOS_TIME / CLK_TCK / 60); Gotoxy (50, 4); CPRINTF ("%. 4f", BIOS_TIME / CLK_TCK / 3600);} Return 0;} function name: BRK function: change data segment space allocation method: int BRK (VOID * endDS); program case: #include
#include
INT main (void) {char * ptr; printf ("Changing allocation with brk () / n"); PTR = malloc (1); Printf ("Before brk () call:% lu bytes free / n", Coreleft )); brk (PTR 1000); Printf ("After BRK () Call:% Lu Bytes Free / N", Coreleft ()); Return 0;} Function Name: BSearch Features: Different Mode Search: Void * BSearch (Const void * key, const void * base, size_t * nlem, size_t width, int (*) (const void *, const *); program: # include # include
#define NELEMS (Arr) (Arr) / SizeOf (Arr [0])) Int NumArray [] = {123, 145, 512, 627, 800, 933}; int Numeric (const * p1, const origin P2) {RETURN (* p1 - * p2);} int Lookup (int key) {Int * Itemptr; / * the cast of (int (*) (const void *, const void *) is needed to avoid a TYPE Mismatch Error At Compile Time * / ITEMPTR = BSearch (& Key, NumArray, Nlems (NumArray), SizeOf (int), (INT) (ITEMPTR! = NULL) } int main (void) {IF (Lookup (512)) Printf ("512 IS in the Table./N"); Else Printf ("512 ISN'T in the Table./N"); Return 0;} Function name: Abort function: exception termination a process usage: void Abort (void); program case: #include
#include
INT main (void) {Printf ("Calling Abort () / N"); Abort (); Return 0; / * this is never reached * /} function name: ABS function: absolute value for integers: int ABS INT i); example: #include
#include
INT main (void) {int Number = -1234; Printf ("Number:% D Absolute Value:% D / N", Number, ABS (Number); Return 0;} Function Name: Absread, Abswirte Features: Absolute Disk Sector read, write data usage: int ABSREAD (int D DRID * BUFFER); int Abswrite (int drive, int nsects, in tsectno, void * buffer); program case: / * Absread Example * / #include
#include
#include
#include
INT main (void) {INT I, STRT, CH_OUT, SECTOR; Char BUF [512]; Printf ("INSERT A Diskette Into Drive A and Press Any Key / N"); getCh (); sector = 0; if (AbsRead (0, 1, Sector, & BUF)! = 0) {Perror ("Disk Problem"); exit (1);} Printf ("Read OK / N"); start = 3; for (i = 0; i < 80; i ) {ch_out = BUF [STRT I]; Putchar ("/ n"); Return ("/ n"); return (0);} function name: Access function: Determine file access rights: int access ( Const char * filename, int _ode);
INT file_exists (CHAR * FileName); int main (void) {Printf ("Does Notexist.fil EXIST:% S / N", File_exists ("NOTEXISTS.FIL")? "YES": "no"); returnograph } int file_exists (char * filename) {return (access (filename, 0) == 0);} function name: ACOS function: Anti-String function method: double acos (double x); program: #include
#include
INT main (void) {Double Result; double x = 0.5; result = acos (x); Printf ("THE ARC COSINE OF% LF IS% LF / N", X, Result); Return 0;}> AllocMem Function: Assign a DOS Storage Segment Usage: int Allocmem (unsigned size, unsigned * seg); program example: #include
#include
#include
INT main (void) {unsigned int size, segp; int stat; size = 64; / * (64 x 16) = 1024 bytes * / stat = allocmem (size, & segp); if (stat == -1) Printf "Allocated Memory At Segment:% x / n", segp); Else Printf ("Failed: Maximum Number of Paragraphs Available IS% U / N", STAT); RETURN 0;} Function Name: ARC Function: Draw an arc Usage: Void Far Arc (int X, int y, int standi, int endangle, int RADIUS); program case: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; int stangle = 45, endangle = 135; int radius = 100; / * initialize graphics and local variables * / INITGRAPH (& gDriver, & gmode, "); / * read results = graphresult (); / * an error er cc {(erroorcode! = grok) {printf (" graphics error:% s / n " GrapherrorMSG ("Press Any Key to Halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy ( ) / 2; setColor ()); / * DRAW ARC * / ARC (MIDX, MIDY, STANGLE, Endangle, Radius); / * Clean Up * / getch (); Closegraph (); return 0;} function name : asctime function: conversion date and time is ASCII code method: char * asctime (const struct tm * tblock); program case: # includ # include
#include
INT main (void) {struct TM T; char STR [80]; / * Sample Loading of TM Structure * / T.TM_SEC = 1; / * seconds * / t.tm_min = 30; / * minutes * / t.tm_Hour = 9; / * Hour * / t.tm_mday = 22; / * day of the month * / t.tm_mon = 11; / * Month * / t.tm_year = 56; / * Year - does not include Century * / T .tm_wday = 4; / * day of the week * / t.tm_yday = 0; / * does not show in assetime * / t.tm_isdst = 0; / * is daylight savtime; does not show in assetime * / / * convers Structure to null terminated string * / strcpy (STR, ASCTIME (& T)); Printf ("% s / n", str); return 0;} function name: ASIN function: Anti-Strove function method: Double Asin (Double X) Draft: #include
#include
INT main (void) {Double Result; double x = 0.5; result = asin (x); Printf ("THE Arc SiN% LF IS% LF / N", X, Result); Return (0);} function name : Assert Features: Test a condition and possibly termination of the usage: void assert; program: #include
# include # include
Struct item {int key; int value;}; / * add item to list, make sure list is not null * / void additem (struct item * itemptr) {assert (itemptr! = null); / * Add item to list * /} int Main (void) {additem (null); Return 0;} function name: ATAN function: Anti-switching function method: Double Atan (double x); program: #include
#include
INT main (void) {Double Result; double x = 0.5; Result = Atan (x); Printf ("The Arc Tangent Of% LF IS% LF / N", X, Result; Return (0);} Function Name : Atan2 function: calculate the U / X of annectious value usage: Double Atan2 (Double Y, Double X); example: #include
#include
INT main (void) {Double Result; double x = 90.0, y = 45.0; result = Atan2 (Y, x); Printf ("The Arc Tangent Ratio OF% LF IS% LF / N", (Y / X), Result); RETURN 0;} function name: ATEXIT function: Register Termination Function Usage: int 3Exit (Atexit_t func); program case: #include
#include
Void exit_fn1 (void) {printf ("exit function # 1 called / n");} void exit_fn2 (void) {printf ("exit function # 2 called / n");} int main (void) {/ * post exit Function # 1 * / atexit (exit_fn1); / * post exit function # 2 * / atexit (exit_fn2); Return 0;} function name: ATOF function: Convert strings into floating point Number usage: Double Atof (const char * nptr Application: #include
#include
INT main (void) {float f; char * str = "12345.67"; f = ATOF (STR); Printf ("String =% s float =% f / n", str, f); Return 0;} function name : atoi function: Converting strings to growth integer: int Atoi (const char * nptr); program case: #include
#include
INT main (void) {int N; char * STR = "12345.67"; n = ATOI (STR); Printf ("String =% s INTEGER =% D / N", STR, N); RETURN 0;} function name : atol function: Conversion of strings to growth integer: long atol (const char * nptr); program case: #include
#include