Turbo C 2.0, Borland C ++ library function and use case

xiaoxiao2021-03-06  88

Turbo C 2.0, Borland C library function and use case

Letter A start function 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); program: #include #include int main (void) {int Number = -1234; Printf ("Number:% D Absolute Value:% D / N", Number, ABS (Number); Return 0;} Function Name: Absread features: absolute disk sector read data usage: int ABSREAD (int DRIVE, INT NSECTS, INT SECTNO, VOID * BUFFER); program case: / * absread example * / # include #include < Conio.h> #include #include int main (void) {Int i, start, ch_out, sector; char buf [512]; printf ("Insert Diskette Into Drive A Press Any Key / N "); getch (); sector = 0; if (Absread (0, 1, Sector, & Buf)! = 0) {PERROR (" Disk Problem "); Exit (1);} Printf (" Read OK / N "); strt = 3; for (i = 0; i <80; i ) {ch_out = buf [start i]; putchar (ch_out);} printf (" / n "); return (0);} Function Name: Abswrite Function: Absolute Disk Sector Write Data Usage: Int Abswrite (int drive, int Nsects, in tsectno, void * buffer); program: / * Abswrite example * / # inclu De #include #include #include int main (void) {INT i, STRT, Ch_out, sector; char buf [512]; printf "INSERT Diskette Into Drive A 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 [start i]; putchar (ch_out);} printf ("/ n "); RETURN (0);} function name: Access function: Determine file access rights limit: int access (const char * filename, int _); program case: #include #include

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 (charge (filename, 0) == 0);} function name: ACOS function: Anti-String function method: Double ACOS (Double X); program case: #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;} function name: AllocMem function: Assign DOS memory segment usage: int allocmem (unsigned size, unsigned * seg); program: #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 SegP); ElsePrintf (" Failed: Maximum Number of Paragraphs Available / IS% U / N ", STAT); RETURN 0;} Function Name: ARC Function: Draw an arc Line usage: Void Far Arc (int X, int y, int in, int end, int RADIUS); program example: #include #include #include #include < Conio.h> 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 opcurred * / if (ErrorCode! = GROK) {Printf ("Graph Err:% 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 ARC * / ARC (MIDX, Midy, Stangle, Endangle, Radius); / * Clean Up * / Getch (); Closegraph (); Return 0;} Function Name: ASCTIME Function: Conversion Date and Time is ASCII Usage: CHAR * ASCTIME (Const struct TM * TBLOCK); CONSTS: #include #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 incrude century * / t.tm_wday = 4; / * day of the week * / t.tm_yday = 0; / * does not show in asctime * / t.tm_isdst = 0; / * Is Daylight SavTime; does not show in asctime * // * converts structure to null terminatedstring * / strcpy (str, asctime (& t )))); Printf ("% s / n", str); return 0;} function name: Asin function: anti-sinus string function method: double asin (double x); program: #include #include < Math.h> 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 function: Test a condition and may stop the program Method: Void assert (int Test); program example: #include #include #include struct item {int key; int value;}; / * add item to list Make Sure List Is Not Null * / Void AddItem (Item * Itemptr) {assert (itemptr! = null);} int main (void) {additem (null); return 0;} function name: ATAN function: Anyway Function usage: Double Atan (double x); program case: #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 Y / X Urgent Create: Double Atan2 (Double Y, Double X) Download 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) , RETURN 0;} function name: ATEXIT function: Register Termination Function Usage: Int AXIT (Atexit_t Func); Procedure: #include #include void exit_fn1 (void) {printf ("Exit function # 1 caled / 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: Double Atof (const char * nptr); program: #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: conversion of string to conversion to total number of use: int Atoi (const char * nptr); program: #include #include int main (void) {INT N; char * STR = "12345.67"; n = atoi (str); Printf ("str, n); return 0;} Function Name: ATOL function: Conversion of strings to growth integer: long atol (const char * nptr); program: #include #include i Nt main (void) {long L; char * STR = "98765432"; l = atol (lstr); Printf ("String =% s INTEGER =% LD / N", STR, L); Return (0);} Letter B start function function name: bar function: draw a two-dimensional bar graph usage: Void Far Bar (int LEFT, INT TOP, INT RIGHT, INT BOTTOM); program: #include #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 result of initialization * / erroorcode =

GraphResult (); if (ErrorCode! = GROK) / * An error acrrred * / {Printf ("Graph Err:% 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 #include #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 result of initialization * / errorcode = graphresult (); if (! errorcode = grOk) / * An error acurred * / {Printf ("graph err:% s / n", grapherrormsg (errorcode)); Printf ("Press AN y Key to Halt: "); getCH (); exit (1); / * terminate with error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; / * loop through the fill pattern * / for (i = empty_fill; i #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 bdockptr (int dosfun, void * argument, unsigned dosal); program: #include #include #include #include #include #include #define buflen 80int main (void) {char buffer [buflen]; INT TEST; Printf ("Enter Full Pathname of A Directory / N); 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: #include #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); CPRI NTF ("... Bioscom [ESC] to EXIT ... / N"); While (! done) {status = bioscom (3, 0, com1); if (status & data_ready) IF ((out = bioscom) 2, 0, COM1) & 0x7F)! = 0) PUTCH (OUT); if (kbhit ()) {i ((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 NSECTS, VOID * BUFFER) 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: Biosequip function: Check device usage: int biosequip Void);: #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: Bioskey function: Directly use the BIOS service keyboard interface usage method: int BIOSKEY (INT CMD); program: #include #include #include #define right 0x01 # define left 0x02 # define ctrl 0x04 # define alt 0x08int main (void) {int key, modifiers; / * function 1 returns 0 Until a key is presssed * / while ( Bioskey (1) == 0); / * function 0 returns the key That is waiting * / key = bioskey (0); / * Use function 2 to determine if Shift key used * / modifiers = bioskey (2); if (Modifiers) {Printf ("["); "Right"); if (Modifiers & Left) Printf ("Left"); if (Modifiers & Ctrl) Printf ("Ctrl"); IF (Modifiers & Alt) Printf ("alt"); Printf ("]");} / * print out the character read * / if (isalNum (Key & 0xFF)) Printf ("'% c' / n", key); Else Printf "% # 02x / n", key); return 0;} function name: BiosMemory function: Return the storage block size usage: int BiosMemory (void); program: #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 Printer I / O Use of BIOS Services: 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 TO Continue / N "); getCH (); status = biosprint (status, abyte, portnum); if (status & 0x01) Printf (" Device Time Out./N ": etc (" I /) PRINTF ("I / O Error./N "); if (status & 0x10) Printf (" SELECTED./N "); if (status & 0x20) Printf (" Out of Paper./N "); if (status & 0x40) Printf (STATUS & 0X40) Printf "Acknowledge./n" "," NOTUS & 0X80) PRINTF ("Not Busy./N"); return 0;} function name: Biostime function: read or set BIOS time usage: long biostime (int CMD, long NewTime);: #include #include #include #include int main (void) {long bios_time; clrs (); 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 Assignment method: int BRK (void * endds); program: #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 function: two binary search usage: void * bsearch (const void * key, const void * base, size_t * nlem, size_t width, int (* fcmp) (Const Void) (Const Void) *, const *); program example: #include #include #define NELEMS (Arr) (Arr) / SizeOf (Arr [0])) Int NumArray [] = { 123, 145, 512, 627, 800, 933}; int Numeric (const * p1, const * p2) {return (* p1 - * p2);} int Lookup (int key) {Int * Itemptr; / * THE CAST OF (INT VOID *, Const Void *) IS ​​NEEDED TO AVOID A TYPE Mismatch Error Atcompile Time * / Itemptr = BSearch (& Key, NumArray, Nlems (NumArray), Sizeof (int), (int) (*) (const void *, const void *)) Numeric); return (itemptr! = null);} int main (void) {if (Lookup (512)) Printf ("512 is in the table./n" ELSEPRINTF ("512 ISN 'THE THE TABLE./N"); RETURN 0;} Alphabet C Bleet Function Function Name: CABS Function: Calculation of Absolute Use: Double Cabs (Struct Complex Z); #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, Val); RETURN 0;} function name: Calloc function: Assign Main memory usage: void * calloc (size_t nlem, size_t elsize); program: #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: Upward: Double CEIL (Double X); Sample 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 Character Series: Char * cgets (char * STR); program example: #include #include int main (void) {char buffer [83]; char * p; / * there's space for 80 characters Plus THE NULL / TERMINATOR * / BUFFER [0] = 81; 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; / * Leave Room for 5 Characters Plus The Null Terminator * / 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 Chdir (Const CHAR * PATH);: #include #include #include char old_dir [maxdir]; char new_dir [maxdir]; int main (void) {if (GetCurdir (0, OLD_DIR)) {Perror ("getCurDir ()"); exit (1);} Printf ("Current Direct) ORY IS: //% S / N ", OLD_DIR); if (chDIR (" // ")) {Perror (" chdir () "); exit (1);} if (getCurdir (0, new_dir)) { "GetCurDir ()"); exit (1); "Current Directory is now: //% s / n", new_dir); Printf ("/ nchanging back to Orignal Directory: //% S / N / ", old_dir); if (chdir (old_dir)) {PERROR (" chdir () "); exit (1);} return 0;} function name: _chmod, chmod function: change file access method: int CHMOD (const char * filename, int permiss);: #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 '' '' % s read-only / n ", filename); ElsePrintf (" MADE% s read-only / n ", filename);} function name: chsize function: change file size usage: int Chsize (int Handle, long size); CHINCLUDE #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: in a given radius (x, y) is a rounded circular usage: 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 Result of Initi AlIzation * / 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 ()); / * 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); program 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 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; 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 Another Message * / Outtextxy (Midx, Midy, "Press any key to quit:"); / * clean up * / getch (); closegraph () Return 0;} function name: Clearerr function: Reset error flag usage: void clearr (file * stream); program: #include int 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 (FP) )) {/ * DISPLAY An Error Message * / Printf ("ERROR ROM DUMMY.FIL / N"); / * reset the Error and EOF INDICATORS * / CLARERR (FP);} fclose (fp); Return 0;} Function Name: ClearViewPort Function: Clear Graphics Viewport (Void Far ClearViewPort (Void); Procedure: #include #include #include #include #define clip_on 1 / * activates clipping in viewport * / int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int ht;

/ * 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 /", GraphherrorMSG (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 key to quit:"); / * clean up * / getch (); closegraph (); return 0;} function name: _close, close function: Close file handle method : Intclose (int Handle); program: #include #include #include #include -1) {Write (Handle, BUF, Strlen (BUF)); / * Close the file * / close (Handle);} Else {Printf ("Error Opening File / N");} return 0;} function Name: CLOCK function: Determine processor time usage: Clock_t clock (void); program: #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; returnograph;

} Function Name: Closegraph Function: Close Graphics System Usage: Void Far Closegraph (Void); Series: #include #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 errooroccurred * / {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 characters in the text window to the end usage: Void Clreol (void); program example: #include int main (void) {clrs CR (); CPrintf ("The function CLREOL CLEARS All Characters from / The / R / N "); CPrintf (" Cursor Position To the End of The Line With / THE / R / N "); CPRINTF (" Current Text Window, With Moving the Cursor./r / N "); CPRINTF (" Press any key to payue.... "); 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; clrs CR (); for (i = 0; i <20; i ) CPrintf ("% D / R / N ", I); CPRINTF (" / R / NPRESS ANY KEY TO CLEAR Screen "); getCh (); CLRSCR (); CPrintf (" The Screen Has Been Cleared! "); getCh (); return 0 ;

} Function name: Coreleft function: Returns the size usage of unused memory: unsigned corlaft (void); program case: #include #include int main (void) {Printf ("The Difference Between THE HIGHEST Allocated / Block and / N "); Printf (" The top of the heap is:% lu bytes / n / ", (unsigned long) Coreleft ()); Return 0;} function name: CoS function: cosine function Usage: Double Cos (Double X); Question: #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 Strove Function: Dluble Cosh (Double X); Procedure: #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: Return to the country information usage: struct country * country (int COUNTRYCODE, STRUCT country * country); program: #include #include #define USA 0int 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 Can: send formatted output to screen usage: int CHAR * format [, argument, ...]); program case: #include int main (void) {/ * clear the screen * / CLRSCR (); / * 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 case: #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: #include #include < String.h> #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 forread and write * / handle = creAT ("Dummy.fil", s_iread | s_iwrite); / * Write 10 bytes to the file * / write (Handle, BUF, STRLEN )); / * Close the file * / close (Handle);} 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 EXSTS./N"); Else {Printf ("Dummy.fil SuccessFully Created./N": Write (Handle, BUF, Strlen); 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: #include #include #include int main (void) {int Handle; char pathname [128]; strcpy (pathname, "//"); / * Create a unique file in the root directory * / handle = createct (Pathname, 0); Printf (" % s Was The Unique File Created./N ", Pathname); Close (Handle); Return 0;} function name: CSCANF function: Formatting input from console: int Cscanf (char * format [, argument,. ..]);: #include int main (void) {char string [80]; / * clear the screen * / clrscr (); / * prompt the user for infut * / 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: convert date and time to 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) (VOID); program example: #include #include #define Abort 0int c_break (void) {Printf ("Control-Break Pressed. Program Aborting .. ./n" "return (abort);}} {ctrlbrk (c_break); for (;;) {printf (" looping ... press to quit: / n "); } return 0;} letter D start function function name: DELAY function: 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); nosound (); return 0;} function name: Delline function: Cut a line of use in text window: Void Delline (Void );: #Include int main (void) {clrs CR (); CPRINTF ("The function Delline Dele Tes / the line containing the / r / n "); CPRINTF (" Cursor and Moves All Lines / Below It One Line Up]); CPrintf ("Delline Operates forin THE / CURRENTLY ACTIVE TEXT / R / N "); CPRINTF (" Window. Press any key to / continue... "); gotoxy (1, 2); / * move the cursor to thesecond line and first column * / getch (); Delline (); getch );} function name: detectgraph function: Determination of graphics drivers and mode usage by detecting hardware: Void Far DetectGraph (int Far * graphmode); program: #include #include #include #include / * names 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 errooroccurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); / * terminate with an errorcode * /} / * display the information detected * / clrs (); printf (" You Have% s video display / credL ./N ", DNAME [GDRIVER]); Printf (" Press Any Key to Halt: "); getch (); return 0;} function name: DiffTime function: calculate time difference between two times: Double DiffTime Time_t Time2, Time_t Time1); program example: #include #include #include #include int main (void) {TIME_T FIRST, SECOND; CLRSCR (); first = Time (null); / * gets system time * / delay (2000); / * waits 2 second * / se COND = Time (null); / * gets system timeagain * / printf ("THE DIFEERENCE IS:% F / Seconds / N", DiffTime (Second, First)); getCh (); return 0;} function name: disable function : interrupt mask usage: void disable (void); procedure example:. / *** NOTE: This is an interrupt serviceroutine You can not compile this programwith Test Stack Overflow turned on andget an executable file that operatescorrectly * / # include #include #include #define INTR 0x1C / * The clock tick interface interrupt * / void interrupt (* oldhandler) (void); int count = 0;

void interrupt handler (void) {/ * disable interrupts during the handling ofthe interrupt * / disable (); / * increase the global counter * / count ; / * reenable interrupts at the end of thehandler * / 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 unsil 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: Remove two integers, returns and remainder: DIV_T (int Number, int DENOM); program: #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 extended DOS error Information usage: int dosexterr (struct doserr * dblkp); program example: #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); PRI NTF ("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",}); Return 0;} function name: dostounix function: conversion date and time is unix Time Format Usage: Long Dostounix (Struct Date * Dateptr, Struct Time * TimePtr); Questions: #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 function: Drawpoly function: Polygon: Void Far DrawPoly (int Numpoints, Int far * polypoints); program case: # 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 localvariables * / 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 (); / * 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 Automatical Closethe Polygon, So We Close It. * / Poly [8] = Poly [0]; POLY [9] = poly [1]; / * Draw the polygon * / DrawPoly (5, poly); / * clean up * / getch (); closegraph (); return 0;} function name: DUP function: copy a file Handle method: int DUP (INT HANDLE); Project: #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 WITHOUTCLOSING 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 handle * / duplacele = DUP (Fileno (stream)); / * Close the duplicate handle to flush has buffer * / close (duphandle);} function name: DUP2 function: Copy file handle: int DUP2 (int in) , int newHandle; Question: #include #include #include #include int main (void) {# define stdout 1int 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 StandardOrdoutput * / oldstdout = dup (STDOUT); / * redirect standard output to DUMMY.FILby duplicating the file handle onto thefile 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 OutputHandle * / DUP2 (Oldstdout, stdout); / * Close DU Plicate Handle For Stdout * / Close (OldStdout); Return 0;} letter E start function function name: ECVT function: Convert a floating point number to a string: 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 ;

/ * scientificNotation * / 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 ellipse usage: Void Far Ellipse (int X, int y, int tenti, int include #include #include #include #include #include #include < STDLIB.H> #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; int stand = 0, endangle = 360; int xradius = 100, yradius = 50; / * initialize graphics, 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 ()); / * Draw Ellipse * / EventiPse (MIDX, Midy, Stangle, Endangle, XRADIUS , Yradius); / * Clean up * / getch (); closegraph (); Retur N 0;} function name: enable function: Open hardware interrupt usage: void enable (void); program case: / * ** Note: this is an interrupt service routine. You can not CompileThis Program with Test Stack overflow Turned On and Get anexecutable file which will operate correctly. * / # include #include #include / * The clock tick interrupt * / # define INTR 0X1Cvoid 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 interface handler * / setVect (Intr, Handler) ; / * loop Until 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); program case: #include #include #include #include #include #include #include void main (int Argc, char * argv []) {INT i; Printf ("Command Line Arguments: / N"); for ( i = 0; i

Printf ("About to Exec Child With Arg1 Arg2 ... / N"); Execv ("Child.exe", Argv); Perror ("Exec Error"); EXIT (1);} Function Name: EXIT Features: Termination Program usage: Void exit (int stat); program: #include #include #include int main (void) {int status; 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); Procedure: #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;} letter F start function function name: FABS function: return floating point number Absolute value method: Double Fabs (Double X); DOUBLE: #include #include int main (void) {float number = -1234.0; Printf ("Number:% f Absolute value: % F / N ", Number, Fabs (Number); RETURN 0;} function name: Farcalloc function: Apply Space usage from the far stack: Void Far * Farcalloc (unsigned long sets, unsigned ling unitsz); Include #include #include #include int main (void) {Char Far * fptr; char * str = "hello"; / * allocate memory for the far pointer * / fptr = farcalloc (10, sizeof (char)); / * Copy "Hello" Into allocated memory * / / * Note : movedata is used because youmight be in a small data model, inwhich case a normal string copy routinecan not be used since it assumes thepointer size is near * / movedata (FP_SEG (str), FP_OFF ​​(str), FP_SEG (fptr),. FP_off (FPTR), Strlen (STR); / * Display String (Note The f Modifier) ​​* / Printf ("Far String IS:% FS / N", FPTR); / * free the memory * / farfree (FPTR) ; Return 0;

} FRCOREFT Function: Returns the unwindless storage area of ​​the unfinished storage: long farcoreleft (void); example: #include #include int main (void) {printf (" The Difference Between The / Highest Allocated Block in The / FAR / N "); Printf (" Heap and the top of the far heap / is:% lu bytes / n ", farcoreleft ()); return 0;} function name: FARFREE Function: Release a piece of usage from a distortion: Void farfree (void); program example: #include #include #include #include int main (void) {char far * fptr; char * str = "hello"; / * allocate memory for the far pointer * / fptr = farcalloc (10, sizeof (char)); / * Copy "Hello" Into allocated memory * / / * Note: movedata is used because you might be in asmall data model, in which case a normal stringcopy routine can not be used since it assumes thepointer size is near * / movedata (FP_SEG (str), FP_OFF ​​(str),. FP_SEG (FPTR), FP_off (FPTR), Strlen (STR)); / * Display String (Note The f Modifier * / Printf ("Far String IS:% FS / N", FPTR); / * free the memory * / farfree (fptr); Return 0;} function name: Farmalloc function: Assign a storage block using aircraft in a distortion: Void Far * Farmalloc (unsigned Long size); Questample: #include #include #include #include int main (void) {char far * fptr; char * STR = "Hello"; / * allocate memory for the far pointer * / fptr = farmalloc (10); / * Copy "Hello" Into allocated memory * /// * Note: MoveData IS Used Because We mightbe in a Small Data Model, in which Casea Normal String Copy Routine Can Not Beused It Assumes The Pointer Sizeis Near. * / MoveData (FP_SEG (STR), FP_OFF ​​(STR), FP_SEG (FPTR), FP_off (FPTR), Strlen (STR)); / * Display String (Note the f modifier * / printf ("FAR STRING IS:% FS / N", FPTR); / * free the memory * / farfree (fptr); Return 0;

} Function name: FarRealloc function: Adjust the allocation block usage in the distinction: Void Far * FarRealloc (Void Far * Block, unsigned long news; program: #include #include int main (void) {Char Far * fptr; fptr = farmalloc (10); Printf ("first address:% fp / n", fptr); FPTR = FarRealloc (FPTR, 20); Printf ("New Address:% fp / n ", fptr); farfree (fptr); Return 0;} function name: Fclose function: Turn off a flow method: int fclose (file * stream); program: #include #include INT main (void) {file * fp; char buf [11] = "0123456789"; / * CREATE A FILE Containing 10 bytes * / fp = fopen ("Dummy.fil", "W"); FWRITE (& BUF, Strlen (buf), 1, fp); / * close the file * / fclose (fp); Return 0;} function name: fcloseall function: Close Open Differential method: int Fcloseall (void); program case: #include int main (void) {int streems_closed; / * open two streams * / fopen ("Dummy.one", "W"); FOPEN ("Dummy.two", "W"); / * Close The Open streams * / streams_closed = fcloseall (); if (streams_closed == EOF) / * issue an error message * / perror ("error"); Else / * Print Result of fcloseall () function * / printf ("% d streams bereclosed) ./N ", streams_cl Od); Return 0;} function name: FCVT function: Convert a floating point number to a string method: char * FCVT (Double Value, int NDIGIT, INT * DECPT, INT * SIGN); program: #include #include #include int main (void) {char * string; double value; int dec, sign; int NDIG = 10; clrs CR (); 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; / * scientificNotation * / ndig = 5; string = ECVT (Value, NDIG, & DEC, & SIGN); Printf ("String =% s Dec =% D / Sign =% D / N", String, DEC, SIGN Return 0;} function name: FDOPEN function: Put the stream with a file handle> File * fdopen (int Handle, Char * Type); program: #include #include #include int main (void) {Int Handle; file * stream; / * open a file * / handle = open ("dummy.fil", o_creat, s_iread | S_IWRITE); / * Now TURN The Handle Into a stream * / stream = fdopen (Handle, "W"); if (stream == null) Printf ("fdopen failed / n"); else {fprintf (stream, " Hello World / N "); fclose (stream);} Return 0;} function name: FeOF function: File end values ​​on the detection stream: int feed (file * stream); program: #include INT main (void) {file * stream; / * open a file forread * / stream = fopen ("Dummy.fil", "R"); / * Read a character from the file * / fgetc (stream); / * Check for EOF * / IF (Feof (streay reached end / n "); / * close the file * / fclose (stream); Return 0;} function name: Ferror function : Detection of erroneous usage: int Ferror (file * stream); program: #include int main (void) {file * stream; / * Open a file for Writing * / stream = fopen ("Dummy.fil", "W"); / * force an error condition by attempting to read * / (void ), getC (stream); if (Ferror) / * Test for An error on the stream * / {/ * display an error message * / printf ("Error Reading from Dummy.FIL / N"); / * RESET The Error and EOF INDICATORS * / CLEARERR (stream);} fclose (stream); Return 0;} function name: FFLUSH function: Clear a flow method: int File * stream; program: #include #include #include #include void flush; file * stream;

INT main (void) {file * stream; char msg [] = "this is a test"; / * create a file * / stream = fopen ("Dummy.fil", "W"); / * Write Some Data TO The File * / FWRITE (MSG, Strlen (MSG), 1, Stream); CLRSCR (); Printf ("Press Any Key to flush / dummy.fil:"); getCh (); / * flush the data to dummy. Fil without / closing it * / flush (stream); Printf ("/ NFile Was Flushed, Press any key / to quit:"); getCh (); return 0;} void flush (file * stream) {int duphandle; / * flush the stream's internal buffer * / fflush (stream); / * make a duplicate file handle * / duphandle = dup (fileno (stream)); / * close the duplicate handle to flush / the DOS buffer * / close (duphandle) } Function name: FGETC function: read characters from the stream: int Fgetc (file * stream); program: #include #include #include int main (void) {file * stream; char string [] = "this is a test"; char ch; / * Open a file for update * / stream = fopen ("Dummy.fil", "W "); / * Write A string into the file * / fwrite (string, string), 1, stream; / * seek to the beginning * / fseek (stream, 0, seek_s ET); do {/ * read a char from the file * / ch = fgetc (stream); / * Display the character * / putch (ch);} while (ch! = EOF); ​​fclose (stream); return 0 (}) Function name: FGetChar function: Read characters from the stream: int FGetChar (Void); program case: #include int main (void) {char ch; / * prompt the user for input * / Printf ("Enter a Character Followed By / :"); / * Read The Character from stdin * / ch = fgetchar (); / * Display What was ready * / printf ("The character read is: '% c '/ n ", ch); RETURN 0;} function name: FGETPOS function: Handle usage of the current file: int FGETPOS (file * stream); program case: #include #include INT main (void) {file * stream;

Char string [] = "this is a test"; fpos_t filepos; / * Open a file for update * / stream = fopen ("Dummy.fil", "w "); / * Write a string inTo the file * / fwrite (String, Strling, 1, Stream); / * Report the file pointer position * / fgetpos (stream, & filepos); Printf ("The File Pointer IS AT BYTE /% LD / N", FilePos); FCLOSE Stream); RETURN 0;} function name: FGETS function: read a series of string from the stream: char * fgets (char * string, int n, file * stream); program example: #include # Include int main (void) {file * stream; char string [] = "this is a test"; char msg [20]; / * Open a file for update * / stream = fopen ("Dummy). Fil "," w "); / * Write a string Into the file * / fwrite (string, string), 1, stream; / * seek to the start of the file * / fseek (stream, 0, seek_set ); / * Read a string from the file * / fgets (msg, string) 1, stream; / * display the string * / printf ("% s", msg); fclose (stream); return 0 } Function name: FileLength function: Take a file length byte number: long filength; example: #include #include #include #include < IO.H> INT Main (void) {int Handle; Char BUF [11] = "0123456789"; / * Create a file containing 10 bytes * / hand = open ("dummy.fil", o_creat); Write (Handle, BUF, Strlen )))); / * Display the size of the file * / printf ("File Length in Bytes:% LD / N", FileLength (Handle)); / * Close The File * / Close (Handle); Return 0;} Function Name: Fillellipse features: Draw and populate an ellipse: Void Far Fillellipse (int X, int y, int xradius, int yradius); program example: #include #include int Main Void) {INT GDRIVER = Detect, Gmode; Int Xcenter, Ycenter, I; Initgraph (& gdriver, & gmode, "); xceenter =

getmaxx () / 2; Ycenter = getmaxy () / 2; for (i = 0; i <13; i ) {setfillstyle (i, white); Fillellipse (Xcenter, Ycenter, 100, 50); getCh ();} Closegraph (); RETURN 0;} function name: FillPoly function: Draw and populate a polygon usage: Void Far FillPoly (int Numpoints, int far * polypoints); program case: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int i, maxx, maxy; / * ur polygon array * / INT POLY [8]; / * Initialize Graphics, Local Variables * / Initgraph (& gdriver, & gmode, ""); / * read results = graphresult (); if (erroorcode! = 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 * /} 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; / * 4th Vertex. FillPoly AutomaticLoses The polygon. * / poly [6] = maxx / 2; poly [7] = maxY / 2; / * loop through the fill pattern * / for (i = Empty_fill; i #include int main (void) {struct ffblfblk; int done; printf ("Directory Listing Of *. * / N"); DONE = FindFirst ("*. *", & ffblk, 0);

While (! DONE) {Printf ("% s / n", ffblk.ff_name); DONE = FindNext (& ffblk);} return 0;} function name: findnext function: search disk directory; get the next matching Findfirst mode File usage: int FindNext (struct ffblk * ffblk); program example: / * Findnext Example * / # include #include int main (void) {struct ffblffblk; int done; printf "Directory Listing Of *. * / N"); DONE = FINDFIRST ("*. *", & Ffblk, 0); While (! DONE) {Printf ("% s / n", ffblk.ff_name); DONE = Findnext (& ffblk);} Return 0;} function name: floodfill function: Fill a boundless region: Void Floodfill (int x, int y, int border); program: #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int Maxx, Maxy; / * Initialize Graphics, 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 * /} maxx = getmaxx (); maxy = getmaxy (); / * select drawing color * / setcolor (getmaxcolor ()); / * select fill color * / setfillstyle (SOLID_FILL, getmaxcolor ()); / * draw a border around the screen * / Rectangle (0, 0, MAXX, MAXY); / * DRAW SOME CIRCLES * / CIRCLE (MAX / 3, MAXY / 2, 50); Circle (Maxx / 2, 20, 100); Circle (MAXX-20, MAXY-50, 75); Circle (20, MAXY-20, 25); / * Wait for a key * / getch (); / * fill in bounded region * / floodfill (2, 2, getmaxcolor ()); / * Clean Up * / getch (); closegraph (); return 0;} function name: floor function: Double-rewarding method: double floor (double x); program: #include #include

INT main (void) {Double Number = 123.54; Double Down, Up; DOWN = FLOOR (Number); Up = CEIL (Number); Printf ("Original Number% 10.2LF / N", Number); Printf ("Number Rounded DOWN% 10.2LF / N ", DOWN); Printf (" Number Rounded Up% 10.2LF / N ", UP); Return 0;} Function Name: Flushall Features: Clear all buffer usage: int flushall (void); program Example: #include int main (void) {file * stream; / * crete a file * / stream = fopen ("Dummy.fil", "W"); / * flush all open streams * / printf ("% d streams were flushed./n" ,flushall());/* close the file * / fclose (stream); Return 0;} function name: FMOD function: calculate x-to-Y size, ie x / y Host Try: Double Fmod (Double X, Double Y); Procedure: #include #include int main (void) {double x = 5.0, y = 2.0; Double Result; Result = FMOD (X, Y); Printf ("THE Remainder of (% LF /% LF) IS /% LF / N", X, Y, Result); Return 0;} function name: fnMerge function: establish a new file name Usage: Void Fnerge (Char * Path, Char * Drive, Char * DIR); Questions: #include #include #include int main (void) {char s [Maxpath]; char driving [maxdrive]; char file [maxfile]; char ext [MAXEXT ]; getcwd (s, maxpath); / * get the current working Directory * / strcat (s, "//"); / * append on a trailing character * / fnsplit (s, drive, dir, file, ext); / * split the string to Separate Elems * / STRCPY (File, "DATA"); STRCPY (EXT, ". TXT"); FnMerge (S, Drive, Dir, File, EXT); / * Merge Everything Into One string * / PUTS (S); / * Display resulting string * / return 0;} function name: FOPEN function: Open a flow method: file * fopen (char * filename, char * type); program case: #include #include #include int main (void) {char * s; char driving [maxDrive]; char file [maxfile]; char ext [MAXEXT]; int [MAXEXT]; int Flags; s = getenv ("

COMSPEC "); / * get the comspec environment parameter * / flags = fnsplit (s, drive, div, file, ext); Printf (" Command Processor Info: / N); if (Flags & Drive) Printf ("/ TDRIVE:% S / N ", DRIVE); if (Flags & Directory) Printf (" / TDIRECTORY:: S / N ", DIR); if (Flags & FileName) Printf (" / TFile:% S / N ", File); if ("/ textension:% S / N", EXT); RETURN 0;} function name: fprintf function: Transfer formatted output to a stream Usage: int FPRINTF (file * stream CHAR * format [, argument, ...]; program example: / * program to create backup of theautoexec.bat file * / # include int main (void) {file * in, * out; IF (("// autoexec.bat", "RT")) == null) {fprintf (stderr, "cannot open infut /file./n" );return 1;}} ((out = FOPEN ("// autoexec.bak", "wt")) == null) {fprintf (stderr, "cannot open output /file./n" );return 1;} while (! feof (in)) FPUTC ( FGETC (in), out; fclose (in); fclose (out); Return 0;} function name: fp_off function: get remote address offset method: unsigned fp_off (Void Far * Farptr); program: / * FP_off * / # include #include int main (void) {char * str = "fpoff.c"; Printf ("the offset of this File In Memory / IS:% FP / N ", FP_OFF ​​(STR)); RETURN 0;} function name: fp_seg function: Get remote address segment value usage: unsigned fp_seg (Void Far * Farptr); program: / * fp_seg * / # include #include int main (void) {char * filename = "fpseg.c"; Printf ("The Offset of this file in memory / is:% fp / n" , Fp_seg (filename)); Return (0);} function name: FPUTC function: Send a character into a stream Usage: int FPUTC (int CH, File * stream); program: #include INT Main (void) {char msg [] = "hello world"; int i = 0; while (msg [i]) {FPUTC (MSG [I], stdout); i ;} return 0;

} Function name: fputchar function: Send a character to standard output stream (stdout): int fputchar (char ch); program case: #include int main (void) {char msg [] = "this IS a test "; int i = 0; while (msg [i]) {fputchar (msg [i]); i ;} return 0;} function name: FPUTS function: send a character to a stream Usage: int FPUTS (char * string, file * stream); program example: #include int main (void) {/ * Write a string to standard output * / fputs ("Hello World / N", stdout); Return 0 } Function name: FREAD function: read data usage from a stream: int 4 (Void * PTR, int size, int nitems, file * stream); program: #include #include int main (void) {file * stream; char msg [] = "this is a test"; char buf [20]; if ((stream = fopen ("Dummy.fil", "W ") == Null ) {FPRINTF (stderr, "cannot open output file./n" );return 1;} / * Write Some Data to the file * / fwrite (MSG, Strlen (MSG) 1, 1, stream; / * seek To the beginning of the file * / fseek (stream, seek_set, 0); / * Read the data and display it * / fread (buf, strlen (msg) 1, 1, stream); Printf ("% s / n ", buf); fclose (stream); RETURN 0;} function name: free function: Release allocated block method: Void Free (Void * PTR); program: #include #include #include int main (void) {char * str; / * allocate memory for string * / str = malloc (10); / * Copy "Hello" to string * / STRCPY (STR, "Hello"); / * Display string * / printf ("String IS% S / N", STR); / * free memory * / free (str); return 0;} function name: FreeMem function : Release the previously assigned DOS memory block: int freemem (unsigned seg); program: #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 <0) Printf ("

Allocated Memory At segment: /% x / n ", segp); Elseprintf (" failed: maximum number of / paragraphone available is% u / n ", stat); freeMem (segp); Return 0;} function name: Freopen function : Replace a flow method: File * Freopen (Char * filename, char * type, file * stream); program: #include int main (void) {/ * redirect standard Output to a file * / if (Freopen ("Output.fil", "W", stdout == NULL) FPRINTF (stderr, "error redirecting / stdout / n"); / * this Output Will Go To a file * / printf ("this will go INTO A File. "); / * Close The Standard Output Stream * / Fclose (stdout); Return 0;} Function Name: FREXP Function: Decompose a double precision number into an index usage method for the mantissa: Double Frexp (Double Value, Int * EPTR); Question: #include #include int main (void) {Double Mantissa, Number; int exponent; number = 8.0; mantissa = frexp (number, & exponent); Printf "THE NUMBER% LF IS", Number; Printf ("% lf Times Two To THE", Mantissa); Printf ("Power Of% D / N", Exponent; Return 0;} function name: fscanf function: from Perform formatting input usage in a stream: int Fscanf (file * stream, char * format [, argument ...]); program example: #include #include int Main (void) {INT I; Printf ("INPUT AN INTEGER:"); / * Read An Integer from thisist Input Stream * / IF (fscanf (stdin, "% d", & i)) Printf ("THE Integer Read WAS :% I / N ", I); else {fprintf (stderr," error reading an / integer from stdin./n" );exit (1); }Return 0;} function name: fseek function: relocation stream File pointer usage: int FSeek (file * stream, long offset, int.comwhere); program: #include long filesis (file * stream); int main (void) {file * stream; stream = fopen ("Myfile.txt", "w "); FPrintf (stream, "this is a test"); Printf ("FileSize of MyFile.txt IS% LD BYTES / N / N /", FileSize (stream);

Fclose (stream);} long filesize (file * stream) {long curpos, length; curpos = ftell (stream); fseek (stream, 0l, seek_ek; length = ftell (stream); FSeek , Seek_set;} function name: FSETPOS function: file pointer on positioning stream: int FSETPOS (File * Stream, Const fpos_t * pOS); program example: #include #include void showpos; int main (void) {file * stream; fpos_t filepos; / * open a file for update * / stream = fopen ("dummy.fil", "w "); / * save The file pointer position * / fgetpos (stream, & filepos); / * Write Some Data to the file * / fprintf (stream, "this is a test"); / * show the current file position * / showpos (stream); / * SET A New File Position, Display It * / IF (FSETPOS (Stream, & FilePos) == 0) ShowPos (Stream); Else {FPrintf (stderr, "error setting file /pointer./n" );Exit (1) } / * close the file * / fclose (stream); Return 0;} void showpos (file * stream) {fpos_t pos; / * Display the current file pointerposition of a stream * / fgetpos (stream, & pos); Printf "File Position:% LD / N", POS);} function name: fstat Function: Get Open File Information Usage: Int Fstat (Char * Handle, Struct Stat * Buff); Procedure: #include #include #include int main Void) {struct stat statbuf; file * stream; / * open a file for update * / if ("Dummy.fil", "W ")) == null) {fprintf (stderr, "cannot Open Output /file./n" ); Return (1 ); }fprintf(stream, "this is a test"); fflush (stream); / * get information about the file * / fstat (Fileno (Stream), & statbuff) Fclose (stream); / * Display the information returned * / if (statbuf.st_mode & s_ifi) PRINTF ("Handle ReferS to a device./n": etc (statbuf.st_mode)

S_ifreg) Printf ("Handle Refers To An ORDINARY /FILE./N": "" "User Has Read Permission on /File./N", Statbuf.st_Mode & S_IWRITE) Printf ("User Has Write Permission ON /FILE./N"); Printf ("Drive Letter of File:% C / N", 'A' Statbuf.st_dev); Printf ("Size of File In Bytes:% LD /1 ,statbuf.st_size, "printf("tf (" Time File Last Opened:% S / N ", CTIME (& statbuf.st_ctime)); Return 0;} Function Name: Ftell Function: Return to Current File Pointer: Long Ftell File * stream); program example: #include int main (void) {file * stream; stream = fopen ("myfile.txt", "w "); FPRINTF (Stream, "this is a test" PRINTF ("The File Pointer IS AT BYTE /% LD / N", Fteam); Fclose (stream); Return 0;} function name: FWRITE function: Write content to stream Usage: int FWRITE (Void * PTR, int size, int nitems, file * stream; program example: #include struct mystruct {INT i; char ch;}; int main (void) {file * stream; struct mystruct s; if (("Test. $$$", "WB")) == NULL) / * Open File Test. $$$ * / {fprintf (stderr, "cannot open output file./n"); Return 1;} Si = 0; s .CH = 'a'; FWRITE (& S , SizeOf (s), 1, stream; / * Write struct S to file * / fclose (stream); / * close file * / return 0;} letter G start function function name: GCVT function: convert floating point numbers into Char * GCVT (Double Value, Int Ndigit, Char * BUF); Question: #include #include int main (void) {char str [25]; Double Num ; int SIG = 5; / * significant Digits * / / / * a regular number * / Num = 9.876; GCVT (Num, SIG, STR); Printf ("String =% S / N", STR); / * a NEGATIVE Number * / num = -123.4567; GCVT (NUM, SIG, STR); Printf ("String =% S / N", STR); / * scientific notation * / Num = 0.678E5;

GCVT (NUM, SIG, STR); Printf ("String =% S / N", STR); RETURN (0);} Function Name: GetArccoRDS Function: Get the last call ARC coordinate usage: Void Far getArccoRDS (Struct ArccoordStype " Far * Arccoords; program example: #include #include #include #include int main (void) {/ * Request Auto Detection * / INT gdriver = DETECT, gmode, errorcode; struct arccoordstype arcinfo; int midx, midy; int stangle = 45, endangle = 270; char sstr [80], estr [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read results = graphresult (); / * an error ire cc {(errorcode! = grok) {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode )); Printf ("Press any key to halt:"); getch (); / * Terminate with an error code * / exit (1);} midx = getmaxx () / 2; midy = getmaxy () / 2; / * Draw arc and get coordinates * / setColor (GetMaxColor ()); Arc (MIDX, Midy, Stangle, Endangle, 100); GetArccoords (& Arcinfo); / * Convert arc information inTo strings * / sprintf (sstr, "* (% D,% D) ", Arcinfo.xstart, Arcinfo.ystart; sprintf (estr, "* - (% D,% d)", arcinfo.xend, arcinfo.ynd); / * Output the arc information * / OutTextxy (Arcinfo.xstart, Arcinfo.ystart, SSTR) Outtextxy (arcinfo.xend, arcinfo.ynd, estr); / * clean up * / getch (); closegraph (); return 0;} function name: getaspectratio function: Return to current graphic mode aspect ratio usage: Void Far getaspectratio (int FAR * XASP, INT FAR * YASP); program example: #include #include #include #include int main (void) {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; INT XASP, YASP, MIDX, MIDY; / * Initialize Graphics and Local Variables * / Initgraph (& gdriver, & g)

Gmode, ""); / * read results = graphresult (); / * an error occurred * / if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode )); Printf ("Press any key to halt:"); getch (); / * Terminate with an error code * / exit (1);} midx = getmaxx () / 2; midy = getmaxy () / 2; SetColor (GetMaxColor ()); / * Get Current Aspect Ratio Settings * / GetASpectratio (& XASP, & YASP); / * Draw Normal Circle * / Circle (MIDX, MIDY, 100); getCh (); / * Draw Wide Circle * / ClearDevice (); setaspectratio (XASP / 2, YASP); Circle (MIDX, MIDY, 100); getch (); / * draw narrow circle * / clearden (); setaspectratio (XASP, YASP / 2); Circle (MIDX, Midy, 100); / * clean up * / getch (); closegraph (); return 0;} function name: getBKCOLOR Function: Return to Current Background Color Usage: Int Far getBkcolor (Void); program: #include #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, ErrorCode; Int Bkcolor, MIDX, Midy; Char Bkname [35]; / * Initialize Graphics and Local Vari Aables * / INITGRAPH (& gDriver, & gmode, "); / * read results = graphresult (); / * an error er c cc {(erroorcode! = grok) {printf (" Graphics error:% s / n ", grapherrormsg (errorcode)); Printf (" Press any key to halt: "); getch (); / * Terminate with an error code * / exit (1);} midx = getmaxx () / 2; Midy = getmaxy () / 2; setcolor (getmaxcolor ()); / * for centering text on the display * / settextjustify (CENTER_TEXT, CENTER_TEXT); / * get the current background color * / bkcolor = getbkcolor (); / * convert color Value Into A String * / ITOA (BKCOLOR, BKNAME, 10); STRCAT (BKNAME, "Is The Current Background Color."

); / * Display a message * / outtextxy (midx, midy, bkname); / * clean up * / getch (); closegraph (); return 0;} function name: getc function: from stream Take a character usage: int Getc (file * stream); program case: #include int main (void) {char ch; printf ("INPUT A Character:"); / * Read a character from thissteandard Input stream * / ch = Getc (stdin); Printf ("THE Character Input Was: '% C' / N", CH); Return 0;} Function Name: getcbrk Features: Get control_break Settings: int GETCBRK (Void); program case: #include < stdio.h> #include int main (void) {if (getcbrk ()) Printf ("cntrl-brk flag is on / n"); ElsePrintf ("cntrl-brk flag is off / n") RETURN 0;} function name: getch function: Nothing back from the console: int GETCH (Void); program: #include #include int main (void ) {char ch; Printf ("Input a character:"); CH = getche (); Printf ("/ NYOU INPUT A '% C' / N", CH); return 0;} function name: getChar function: from STDIN stream reading characters usage: int getchar (void); program case: #include int main (void) {int C; / * Note That GetChar Reads from stdin andis line buffered; this Means It WillnotNot Return Until You press enter. * / while ((c = getchar ())! = '/ n') PRIN TF ("% C", c); return 0;} function name: getChe function: Take the character (brought back "usage from the console: int GETCHE (VOID); program: #include #include int main (void) {char ch; Printf ("Input a character:"); ch = getChe (); Printf ("/ NYOU INPUT A '% C' / N", CH); Return 0 } Function name: getColor function: Return the current line color usage: int Far getColor (Void); program: #include #include #include #include #include int main (void) {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; Int Color, MIDX, Midy; Char ColName [35];

/ * Initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error occurred * / if (! Errorcode = grOk) {printf ( "Graphics Error:% S / N", GraphherrorMsg (ErrorCode)); Printf ("Press any key to halt:"); getch (); / * Terminate with an error code * / exit (1);} midx = getmaxx () / 2; Midy = getmaxy () / 2; setColor (getMaxColor ()); / * for centering text on the display * / settextjustify (center_text, center_text); / * get the current drawing color * / color = getColor ); / * Convert Color Value Into A String * / ITOA (Color, ColName, 10); Strcat (ColName, "Is The Current Drawing Color); / * Display A Message * / Outtextxy (MIDX, Midy, Colname) ; / * CLOAN UP * / GETCH (); closegraph (); return 0;} function name: getCurdir function: Take the current directory usage of the specified drive: int GetCurdir (int drive, char * DIREC); program: #include < Dir.h> #include #include char * current_directory (char * path) {structure (path, "x: //"); / * Fill String with form of response: x: / * / path [0] = 'a' getDisk (); / * RE place X with current drive letter * / getcurdir (0, path 3); / * fill rest of string with current directory * / return (path);} int main (void) {char curdir [MAXPATH]; current_directory (curdir) PRINTF ("THE CURRENT DIRECTORY IS% S / N", CURDIR); RETURN 0;} Function Name: GetCWD Function: Take Current Work Directory Usage: Char * GetCwd (CHAR * BUF, INT N); Project: #include #include int main (void) {char buffer [maxpath]; getcwd (buffer, maxpath); Printf ("THE CURRENT DIRECTORY IS:% S / N", Buffer; Return 0 } Function name: getDate function: Take DOS date usage: void getdate (struct * dateblk); program case: #include #include int main (void) {struct date d; getDate & d);

Printf ("THE CURRENT YEEAR IS:% D / N", D.DA_Year); Printf ("THE CURRENT DAY IS: D / N", D.DA_DAY); Printf ("THE CURRENT MONTH IS:% D / N ", D.DA_MON); RETURN 0;} function name: getDefaultPalette function: return palette definition structure usage: struct pastettype * Far getDefaultpalette (void); program case: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int i; / * structure for return Plette Copy * / Struct palettetype far * pal = (void *) 0; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error occurred * / if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCh (); / * Terminate with an error CODE * / exit (1);} setColor ()); / * Return a pointer to the default paste * / pal = getDefaultpalette (); for (i = 0; i <16; i ) {printf ("colors % D] =% D / N ", I, PAL-> Colors [i]); getCh ();} / * clean up * / getch (); return 0;} function name: getDFree function: Take Disk Free Space Usage: Void getDFree (int DRIVE, STRUCT DFREE * DFREEP); program example: #include #include #include #include int main (void) {struct DFree Free; Long Avail; Int Drive; Drive = getDisk (); getDFree (Drive 1, & Free); if (Free) .df_sclus == 0xfff) {Printf ("Error IN getDfree () call / n"); exit (1);} avail = (long) free.df_avail * (long) free.df_sclus; Printf ("DRIVE% C: HAS% LD BYTES / AVAILABLE / N", 'A' Drive, Avail; Return 0;

} Function name: getDisk function: Take the current disk drive number: int getDisk (void); example: #include #include int main (void) {int disk; disk = getDisk ) 'A'; Printf ("THE CURRENT DRIVE IS:% C / N", DISK); RETURN 0;} Function Name: GetDriverName Features: Returns a string pointer usage containing the current graphics driver name: char * getDrivename (void); Question: #include #include #include #include int main (void) {/ * Request Auto Detection * / int GDRIVER = DETECT, gmode, errorcode; / * stores the device driver name * / char * drivername; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error o c (errorcode! = grok) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCH ( ); / * terminate with an error code * / exit (1);} setColor ()); / * get name of the device driver in use * / drivername = getDrivername (); / * for centering text on the screen * / setTextJustify (center_text, center_text); / * Output the name of THE DRIVER * / OUTTEXTXTXY (getmaxx () / 2, getmaxy () / 2, drivername); / * clean up * / getch (); closegraph (); return 0;} function name: getDTA function: Take the disk transfer address usage : char far * getdta (void); Question: #include #include int main (void) {char far * dta; dta = getdta (); Printf ("The Current Disk Transfer / address is:% fp / n ", DTA); RETURN 0;} function name: getENV function: string from the environment: char * getenv (char * envvar); example: #include #include int main (void) {char * s; s = getenv ("comspec"); / * get the comspec environment parameter * / printf ("Command Processor:% S / N", S); / * DISPLAY COMSPEC Parameter * / Return 0;

} Function name: getfat, getfatd function: Take file allocation table information usage: void getfat (int drive); program: #include #include int main (void) {struct fatinfo diskinfo; int flag = 0; Printf ("please insert disk in drive a / n"); getChar (); getfat (1, & diskinfo); / * get drive information * / printf ("/ ndrive A: IS "); Switch (UNSIGNED Char) {case 0xfd: Printf (" 360k low density / n "); Break; Case 0xF9: Printf (" 1.2 meg high density / n "); Break; Default: Printf ("unformatted / n"); flag = 1;} if (! flag) {Printf ("Sectors Per Cluster% 5D / N", Diskinfo.fi_SClus; Printf ("Number of Clusters% 5D / N", DiskInfo. Fi_nclus); Printf ("Bytes Per Seor% 5D / N", DiskInfo.fi_Bysec);} Return 0;} function name: getFillPattern function: copy user-defined fill mode to memory: Void Far getFillPattern (Char Far * Upattern); program case: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = Detect, Gmode, ErrorCode; int Maxx, Maxy; char pattern [8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x 04}; / * 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 * / } MAXX = getMaxx (); MAXY = getMaxy (); setColor (getMaxColor ()); / * SELECT A user defined Fill Pattern * / setFillPattern (Pattern, getmaxcolor ()); / * Fill the screen with the pattern * / bar (0, 0, Maxx, Maxy; getCH ();

/ * Get the current user defined Fill Pattern * / getfillpattern (Pattern); / * alter the pattern we grabbed * / pattern [4] - = 1; pattern [5] - = 3; pattern [6] = 3; Pattern [7] - = 4; / * Selectur new pattern * / setfillpattern (Pattern, getmaxcolor ()); / * Fill the screen with the new pattern * / bar (0, 0, maxx, maxy); / * Clean Up * / getch (); closegraph (); return 0;} function name: getFillSettings function: Acquisition of information about current fill mode and filling color: Void Far getFillSettings (Struct FillSettingstype Far * FillInfo); program case: #include #include #include #include / * the names of the weight "supported * / char * fname [] = {" EMPTY_FILL "," Solid_Fill ", "LINE_FILL", "LTSLASH_FILL", "SLASH_FILL", "BKSLASH_FILL", "LTBKSLASH_FILL", "HATCH_FILL", "XHATCH_FILL", "INTERLEAVE_FILL", "WIDE_DOT_FILL", "CLOSE_DOT_FILL", "USER_FILL"}; int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; struct fillsettingstype fillinfo; int midx, midy; char patstr [40], colstr [40]; / * initialize graphics and local variables * / in ITGRAPH (& gDriver, & gmode, "); / * read result itis = graphresult (); if (erroorcode! = 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; / * get information about current fill pattern and color * / getfillsettings (& fillinfo); / * convert fill information into strings * / sprintf (patstr, "% s is the fill style.", fname [fillinfo.pattern ]);

sprintf (colstr, "% d is the fill color.", fillinfo.color); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, patstr); outtextxy (midx, midy 2 * TextHeight ("w"), colstr); / * clean up * / getch (); closegraph (); return 0;} function name: getftime function: Take a Date Date and Time Usage: Int getftime (int Handle, Struct Ftime * FTIMEP); program example: #include #include int main (void) {file * stream; struct ftime ft; if ((stream = fopen ("Test. $$$", " WT ")) == null) {fprintf (stderr," cannot open output file./n" ";return 1;} Getftime (Fileno (Stream), & ft); Printf ("File Time:% u:% u: % u / n ", ft.ft_Hour, ft.ft_min, ft.ft_tsec * 2); Printf (" File Date:% U /% U /% U / N ", ft.ft_month, ft.ft_day, ft.ft_year 1980); fclose (stream); Return 0;} function name: getGraphmode function: Return to current graphics mode: int Far getgraphmode (void); program: #include #include # INCLUDE #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy, mode; char number [80], modename 80]; / * Initializ e graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error occurred * / if (! errorcode = grOk) {printf ( "Graphics Error:% S / N ", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getch (); / * Terminate with an error code * / exit (1);} midx = getmaxx () / 2; midy = getmaxy () / 2; / * get mode number and name strings * / mode = getgraphmode (); sprintf (Numname, "% d is the current mode number.", Mode); sprintf (modename, " % s is the current graphics mode ", getModename (MODE));

/ * Display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, numname); outtextxy (midx, midy 2 * textheight ( "W"), modename); / * clean up * / getch () Closegraph (); RETURN 0;} function name: getimage function: save a bitmap of the specified area to the main memory: Void Far GetImage (int LEFT, INT TOP, INT RIGHT, INT BOTTOM, VOID FAR * BITMAP) ;: #Include #include #include #include #include void save_screen (void far * buf [4]) Void restore_screen (Void Far * BUF [4]); int MAXX, MAXY; int main (void) {INT GDRIVER = Detect, Gmode, ErrorCode; Void Far * Ptr [4]; / ​​* auto-detect the graphics driver and Mode * / initgraph (& gdriver, & gmode, "); erroorcode = graphresult (); / * check for any errors * / if (ErrorCode! = GROK) {Printf (" Graphics Error:% S / N ", GrapherrorMSG (ErrorCode )); Printf ("Press any key to halt:"); getCh (); exit (1);} maxx = getmaxx (); maxy = getMaxy (); / * draw an image on the screen * / reccTangle (0 , 0, MAXX, MAXY; LINE (0, 0, Maxx, Maxy); Line (0, Maxy, Maxx, 0); Save_Screen (PTR); / * Save th e current screen * / getch (); / * pause screen * / clearden * / restore_screen (PTR); / * restore the screen * / getch (); / * pause screen * / closegraph () Return 0;} void save_screen (Void Far * BUF [4]) {Unsigned size; int ystart = 0, Yend, Yincr, Block; Yincr = (Maxy 1) / 4; Yend = Yincr; Size = imagesize (0 , YSTART, MAXX, YEND; / * GET BYTE SIZE OF Image * / for (Block = 0; Block <= 3; Block ) {IF ((BUF [block] = farmalloc (size) == null) {Closegraph (); Printf ("Error: Not enough Heap space in save_screen () /./ n"); exit (1);} getImage (0, ystart, maxx, yend, buf [block]); YStart = Yend 1 ;

Yend = yincr 1;}} void restore_screen (Void Far * BUF [4]) {Int YStart = 0, Yend, Yincr, Block; Yincr = (MAXY 1) / 4; Yend = Yincr; for (block = 0; Block <= 3; Block ) {PUTIMAGE (0, YSTART, BUF [Block], COPY_PUT); Farfree (BUF [Block]); YSTART = YEND 1; Yend = YINCR 1;}} function name: GetLineSettings Features: Take current line type, mode and width: Void Far getLineSettings (Struct Linesettingstype Far * LiniNfo); program: #include #include #include #include / * the name {"Solid_Line", "Dotted_Line", "DOTTED_LINE", "DOTTED_LINE", "DOTTED_LINE", "DASHED_LINE", "Userbit_Line"}; int main (void) { / * request auto detection * / int gdriver = DETECT, gmode, errorcode; struct linesettingstype lineinfo; int midx, midy; char lstyle [80], lpattern [80], lwidth [80]; / * initialize graphics and local variables * / INITGRAPH (& gDriver, & gmode, "); / * read results = graphresult (); if (errorcode! = grok) / * an error occrred * / {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; / * get information About Current Line Settings * / GetLineSettings (& LineInfo); / * Convert Line Information INTO STRINGS * / SPRINTF (LStyle, "% s is the line style); sprintf (lpattern," 0x% XIS The user-defined line pattern; "LINEINFO.UPATTERN); Sprintf (LWIDTH,"% D is the line thinkness. ", lineInfo.thickness); / * Display the information * / setTextJustify (center_text, center_text);

Outtextxy (MIDX, MIDY, LSTYLE); OUTTEXTXY (MIDX, MIDY 2 * TextHeight ("W"), LPATTERN; OUTTEXTXY (MIDX, MIDY 4 * TextHeight ("W"), LWIDTH; / * Clean Up * / getch (); closegraph (); return 0;} function name: getMaxColor function: Return to the maximum color value of the function setColor: int Far getMaxColor (Void); program: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; char col 4tr [80 ]; / * 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; / * grab the color info. and communication it to a string * / sprintf (colstr, "this mode supports colors 0 ..% d", getmaxcolor ()) ; / * Display the information * / setTextJustify (center_text, center_ Text); OutTextxy (MIDX, MIDY, ColStr); / * clean up * / getch (); closegraph (); return 0;} function name: getMaxx function: Return to the maximum X coordinate usage: int Far getMaxx (Void) : #Include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; char xrange [80], yrange [80]; / * 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 ("Press Any Key to Halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy ( ) / 2; / * Convert Max resolution value Into strings * / sprintf (xrange, "x values ​​range from 0 ..% d", getmaxx ()); sprintf (YRANGE, "Y VALUES RANGE FROM 0 ..% D" , getmaxy ()); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, xrange); outtextxy (midx, midy textheight ( "W"), yrange); / * clean up * / getch (); closegraph (); return 0;} function name: getMaxY function: return screen's maximum y coordinate usage: int Far getMaxY (void); program: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; char xrange [80], yrange [ 80]; / * 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; / * Convert Max Resolution Values ​​INTO STRINGS * / SPRINTF (Xrange, "X Values ​​Range from 0 ..% D", getMaxx ()); Sprintf (YRANGE, "Y VALUES RANGE FROM 0 ..% D", GetMax ()); / * Display the information * / settextjustify (center_text, center_text); Outtextxy (MIDX, MIDY, Xrange); Outtextxy (MIDX, Midy Textheight ("W"), YRANGE); / * Clean Up * / getch (); return 0;} function name: getModename function: Returns a string pointer usage containing the specified graphic mode: Char * Far getModename (int mode_name); program case: #include <

Graphics.h> #include #include #include int main (void) {/ * request autodtection * / int gDriver = detect, gmode, errorcode; int MIDX, Midy , mode; char numname [80], modename [80]; / * 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; / * get mode number and name strings * / mode = getgraphmode (); sprintf (numname, "% d is the current mode number. ", mode); sprintf (modename,"% s is the current graphics mode ", getmodename (mode.)); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, Midy, NumName); Outtextxy (MIDX, MIDY 2 * TextHeight ("W"), Modename); / * Clean Up * / getch (); closegraph (); return 0;} function name: getModeRange function: feed Graphical driver mode range : Void Far getModeraNge (Int graphDriver, int far * inclus: #include #include #include int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; int low, high; char mrange [80]; / * 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; / * get the mode ranging for this driver * / getModerange (gdriver, & low, & high); / * Convert MODE range info into strings * / sprintf (mrange, "This driver supports modes% d ..% d", low, high);. / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, mrange ); / * clen up * / getch (); closegraph (); return 0;} function name: getPalette function: Return information usage about current palette: Void Far getPalette (Struct PaletType Far * Palette); #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode Struct PaletType Pal; Char Psize [80], PVAL [20]; INT I, HT; INT Y = 10; / * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * Read Result of Initialization * / errorcode = graphresult (); / * an error {Printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("Press Any Key to Halt) : "); getch (); / * Terminate with an error code * / exit (1);} / * grab a copy of the palette * / getpalette (& par); / * Convert Palette info. INTO STRINGS * / SPRINTF Psize, "The Palette Has% D / Modifiable Entries.", PAL.SIZE); / * Display THE INFORMATION * / OUTTEXTXTXY (0, Y, PSize); if (Pal.Size! = 0) {ht = textheight (" W "); y = 2 * ht; Outtextxy (0, y," here is the current / value: "); y = 2 * ht; for (i = 0; i

} GetPass function: read a password usage: char * getpass (char * prompt); program: #include int main (void) {char * password; password = getPass ("Input a password: "); CPRINTF (" THE Password IS:% S / R / N ", Password); RETURN 0;} function name: getpixel function: Color usage of specified pixels: int 4, int x, int y) Example: #include #include #include #include #include #define pixel_count 1000 # define delay_time 100 / * in MilliseConds * / int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int i, x, y, color, maxx, maxy, maxcolor, seed; / * initialize graphics and local variables * / initgraph (& gDriver, & gmode, ""); / * read result = graphresult (); / * an error er cc {(erroorcode! = grok) {printf ("Graphics Error:% S / N", GrapherrorMsg (ERRORCODE)); Printf ("Press any key to halt:"); getch (); / * Terminate with an error code * / exit (1);} maxx = getmaxx () 1; maxy = getMaxy () 1; maxColor = getmaxcolor () 1; while (! Kbhit ()) {/ * seed the random Number G Enerator * / seed = Random (32767); SRAND (seed); for (i = 0; i int main (void) {char string [80]; printf ("INPUT A String:"); Gets (string); printf ("

The String Input WAS:% S / N ", String); Return 0;} Function Name: GetText Function: Copy the text on the text Method to Storage Area: Int gettext (int LEFT, INT TOP, INT Right, int Bottom, void * destin; program: #include char buffer [4096]; int main (void) {INT i; clrs CR (); for (i = 0; i <= 20; i ) CPrintf ("Line #% D / R / N", I); GetText (1, 1, 80, 25, Buffer); gotoxy (1, 25); CPrintf ("Press Any Key To Clear Screen ..."); Getch (); CLRSCR (); gotoxy (1, 25); cprintf ("press any key to restore ..."); getCh (); PUTTEXT (1, 1, 80, 25, buffer); gotoxy (1 , 25); CPRINTF ("Press any key to quit ..."); getch (); return 0;} function name: getTextinfo function: Take text mode display information usage: void getTextinfo (struct text_info * inforec); program Example: #include int main (void) {struct text_info ti; gettextinfo (& Ti); CPRINTF ("Window Left% 2D / R / N", Ti.WinLeft); CPRINTF ("Window Top% 2D / R / n ", Ti.wintop); CPRINTF (" Window Right% 2D / R / N ", Ti.WINRight); CPrintf (" Window Bottom% 2D / R / N ", Ti.winbottom; CPrintf (" Attribute) % 2D / R / N ", Ti.attribute); CPRINTF (" Normal Attribute% 2D / R / N ", Ti.Normattr); CPRINTF (" Current Mode% 2D / R / N ", Ti .currmode; cprintf ("Screen Height% 2D / R / N", Ti.ScreenHeight); CPrintf ("Screen Width% 2D / R / N", Ti.Screenwidth; CPRINTF ("Current X% 2D / R / N ", Ti.Curx; CPRINTF (" Current Y% 2D / R / N ", TI.CURY); RETURN 0;} Function Name: GetTextSettings Features: Returns information about current graphic text font: Void Far getTextSettings Struct TextSettingStype Far * TextInfo); Drafts: #include #include #include #include / * The names of the fonts supported * / char * Font [] = {"default_font", "triplex_font", "small_font", "sans_serif_font", "gothic_font"};

/ * The names of the text directions supported * / char * dir [] = { "HORIZ_DIR", "VERT_DIR"}; / * horizontal text justifications supported * / char * hjust [] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT"}; / * vertical text justifications supported * / char * vjust [] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT"}; int main (void) {/ * request auto detection * / int gdriver = DETECT , gmode, errorcode; struct textsettingstype textinfo; int midx, midy, ht; char fontstr [80], dirstr [80], sizestr [80]; char hjuststr [80], vjuststr [80]; / * initialize graphics and local variables * / INITGRAPH (& gDriver, & gmode, "); / * read results = graphresult (); if (erroorcode! = 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; / * get information about current text settings * / gettext settings (& textinfo); / * Convert text information insto strings * / SPR INTF (FontStr, "% s is the text", font [textinfo.font]); sprintf (DIRSTR, "% s is the text direction.", DIR [textInfo.direction]); sprintf (Sizestr, "% D is the text size. ", textinfo.charsize; sprintf (hjuststr,"% s is the horizontal justification. ", hjust [textinfo.horiz]); sprintf (vjuststr,"% s is the vertical justification. ", vjust [textinfo.vert]); / * display the information * / ht = textheight ( "W"); settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, fontstr); outtextxy (midx, midy 2 * ht, dirstr ); OutTextxy (MIDX, MIDY 4 * HT, SIZESTR);

Outtextxy (MIDX, MIDY 6 * HT, HJUSTSTR); Outtextxy (MIDX, MIDY 8 * HT, VjustStr); / * Clean Up * / getch (); Closegraph (); return 0;} function name: getTime function: Time usage: void gettime (struct time * timep); program case: #include #include int main (void) {struct time t; gettime (& t); printf ("THE Current Time IS:% 2D:% 02D:% 02D.% 02D / N ", T.Ti_Sec, T.Ti_MIN, T.TI_SEC, T.TI_HUND); RETURN 0;} Function Name: GetVect Function: Get Interrupt Vector Inlet Usage: Void Interrupt (* getvect (int INTR_NUM)); Questions: #include #include void interrupt get_out (); / * interrupt prototype * / void interrupt (* Oldfunc) () ; / * Interrupt Function Pointer * / INT looping = 1; int Main (void) {PUTS ("Press to Terminate); / * save the old interrupt * / oldfunc = getVect (5); / * Install Interrupt Handler * / setVect (5, get_out); / * do nothing * / while (looping); / * restore to Original Interrupt Routine * / setVect (5, OldFunc); PUTS ("Success"); return 0 } void interrupt get_out () {looping = 0; / * Change global variable to get out of loop * /} function name: getverify function: Return DOS check flag status usage: in T getverify; program example: #include #include int main (void) {if (getverify ()) Printf ("DOS VERIFY FLAG IS ON / N"); ElsePrintf "DOS Verify Flag IS Off / N"); Return 0;} Function Name: GetViewSetting Features: Returns information about current view: Void Far getViewSettings (Struct ViewPortType Far * Viewport; program: #include #include #include #include char * clip [] = {"OFF", "on"}; int main (void) {/ * Request Auto Detection * / int gDriver = detect, gmode, errorcode; struct viewporttype viewinfo; int midx, midy, ht; char TOPSTR [80], BOTSTR [80], Clipstr [80];

/ * 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", GraphherrorMsg (ErrorCode)); Printf ("Press any key to halt:"); getch (); exit (1); / * Terminate with an error code * /} midx = getMaxx () / 2; Midy = getMaxy () / 2; / * GET INFORMATION ABOT CURRENT VIEWPORT * / GETVIEWSETTINGS (& ViewInfo); / * Convert Text Information INTO STRINGS * / SPRINTF (Topstr, "(% D,% d) is the the Upper Left ViewPort Corner. ", ViewInfo.Left, ViewInfo.top); Sprintf (Botstr," (% D,% d) is the Lower Right Viewport Corner. ", ViewInfo.Right, ViewInfo.Bottom; Sprintf (Clipstr, "Clipping is turned% s.", clip [viewinfo.clip]); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); ht = textheight ( "W"); outtextxy (midx, midy, topstr); outtextxy (MIDX, MIDY 2 * HT, BOTSTR); OUTTEXTXY (MIDX, MIDY 4 * HT, Clipstr); / * clean up * / getch (); closegraph (); return 0;} function name: GetW function: from Take an integer usage in the stream: INT GETW (File * Strem); Questions: #include #include #define fname "TEST. $$$" int main (void) {file * fp; int word; / * Place the Word IN A File * / fp = fopen (FNAME, "WB"); if (fp == null) {Printf ("Error Opening File% S / N", FNAME); EXIT (1);} Word = 94; PUTW (Word, FP); if ("Error Writing to File / N"); ElsePrintf ("Successful Write / N"); Fclose (FP); / * Reopen THE FILE * / FP = FOPEN (FNAME, "RB"); if (fp == null) {Printf ("Error Opening File% S / N", FNAME); EXIT (1);} / * extract the word * / word = getw (fp); if (FERROR (FP)) Printf ("

Error Reading File / N "); ElsePrintf (" Successful Read: Word =% D / N ", Word); / * Clean Up * / Fclose (FP); unlink (fname); Return 0;} function name: Getx function : Returns the X coordinate usage of the current graphic location: int Far getx (void); program example: #include #include #include #include int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; char msg [80]; / * 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 * /} / * Move To the screen center point * / moveto (getmaxx () / 2, getmaxy () / 2); / * Create a message string * / sprintf (msg, "<- (% d,% d) is the here.", getX (), getY ()); / * Display the message * / OutText (msg); / * clean Up * / getch (); closegraph (); return 0;} function name: getY function: Returns the y coordinate usage of the current graphics location: int Far gety (void); program: #include # Include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; char msg [80]; / * 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 * /} / * move to the the the the Screen Center Point * / MoveTo (getmaxx () / 2, getmaxy () / 2);

/ * CREATE A Message String * / Sprintf (MSG, "<- (% D,% d) is the here.", getX (), gety ()); / * Display the message * / OutText (msg); / * Clean Up * / getch (); closegraph (); return 0;} function name: GMTIME function: Convert date and time to GMT Time (GMT) Usage: StructTM * GMTIME (long * clock); #include #include #include #include / * pacific standard time & daylight savings * / char * tzstr = "tz = pst8pdt"; int main (void) {TIME_T T; STRUCT TM * GMT, * area; Putenv (Tzstr); Tzset (); T = Time (NULL); Area = LOCALTIME (& T); Printf ("Local Time IS:% S", asctime (AREA)); GMT = GMTIME (& T); Printf ("GMT IS:% S", ASCTIME (GMT)); RETURN 0;} function name: gotoxy function: Set cursor usage in the text window: Void gotoxy (intoxxy) X, int y); program example: #include int main (void) {clrs CR (); gotoxy (35, 12); CPrintf ("Hello World"); getCh (); return 0;} function Name: graphdefault function: Reset all graphic settings for their default value: Void Far GraphDefaults (Void); program: #include #include #include # INCLUDE int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; in T maxx, maxy; / * Initialize graphics and local variables * / initgraph (& gdriver, & gmode, "c: // bor // borland // bgi"); / * 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 * /} maxx = getmaxx (); maxy = getMaxy (); / * Output line with non-default settings * / setLinesTyle (Dotted_Line, 0, 3); line (0, 0 , Maxx, Maxy; Outtextxy (MAXX / 2, MAXY / 3, "Before default values ​​are rest."

Getch (); / * restore default value for everything * / graphdefaults (); / * clear the screen * / clearden (); / * Output line with default settings * / line (0, 0, maxx, maxy); Outtextxy (MAX / 2, MAXY / 3, "After Restoring Default Values."); / * CLOAN UP * / GETCH (); Closegraph (); Return 0;} Function Name: GrapherrorMSG Function: Return to an Error String Pointer Usage: CHAR * FAR Grapherror (int errorcode); program example: #include #include #include #include #define nonsense -50int main (void ) {/ * FORCE AN ERROR TO OCCUR * / int gdriver = NONSENSE, gmode, errorcode; / * initialize graphics mode * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult () ; / * if an error // * descriptive error message. * / if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("" Press any key to halt: "); getCH (); exit (1); / * terminate with an error code * /} / * draw a line * / line (0, 0, getmaxx (), getmaxy ()); / * CLOAN UP * / GETCH (); Closegraph (); Return 0;} function name: GraphResult function: Returns the last unsuccessful graphic operation error code usage: int Far GraphResult (void); program example: #include #include #include #include int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; / * 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 * /} / * draw a line * / line (0, 0, getmaxx (), getmaxy ()); / * clean up * / getch (); closegraph (); return 0;} Function name: _GraphFreemem function: User-can modify graphics storage area release function usage: void far _Graphfreemem (Void Far * PTR, unsigned size); program: #include #include #include < Stdio.h> #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; / * clear the text Screen * / clrs (); PRINTF ("Press any key to initialize graphics mode:"); getch (); clrscr (); / * 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; / * display a message * / setTextJustify (Center_text, center_text); Outtextxy (MIDX, Midy, "Press Any Ke Y to exit graphics mode: "); / * clean up * / getch (); closegraph (); return 0;} / * called by the graphics kernel to allocate memory * / void far * fal _GraphgetMem (unsigned size) {printf ("_GraphgetMem Called to Allocate% D Bytes./n", Size) ;printf (" Hit Any Key: "); getCh (); Printf (" / n "); / * Allocate Memory from Far Heap * / Return Farmalloc (size);} / * called by the graphics kernel to free memory * / void far _graphfreeMem (Void Far * Ptr, unsigned size) {printf ("_ graphfreemem called to free% d bytes./n", size); printf "Hit any key:"); getCh (); Printf ("/ n"); / * free Ptr from Far Heap * / Farfree (PTR);

} Function Name: _GraphgetMem Function: User-can modify graphic storage area allocation function: void far * far _graphgetMem (unsigned size); program: #include #include #include #include #include int main (void) {/ * request autodtection * / int gDriver = detect, gmode, errorcode; int midx, midy; / * clear the text screen * / CLRSCR (); Printf ("Press any key to initialize graphics mode:"); getCh (); clrscr (); / * 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; / * display a message * / settextjustify (center_text, Center_text); Outtextxy (MIDX, Midy, "Press Any Key to EXIT Graphics Mode:"); / * Clean Up * / Getch (); Closegraph (); Return 0;} / * called by the graphics kernel to allocate memory * / void far * far _gr AphgetMem (unsigned size) {printf ("_ graphgetmem called to allocate% D bytes./n" ,size) ;printf (" Hit Any Key: "); getCH (); Printf (" / n "); / * Allocate Memory from far heap * / return farmalloc (size);} / * called by the graphics kernel to free memory * / void far _graphfreemem (void far * ptr, unsigned size) {printf ( "_ graphfreemem called to free% d bytes./n ", size); Printf (" Hit any key: "); getCh (); Printf (" / n "); / * free Ptr from Far Heap * / farfree (PTR);} letter h start function function name: HARDERR Function: Create a hardware error handler usage: Void Harden (int (* fptr) ());

Example: / * This Program Will Trap Disk Errors and Promptthe User For Action. Try Running It With Nodisk In Drive A: To Invoke Its Functions. * / # Include #include #include < DOS.H> #define ignore 0 # define retry 1 # define abort 2int buf [500]; / * define the error message for trapping disk problems * / static char * err_msg [] = {"Write Protect", "Unknown Unit" "Drive Not Ready", "Data Error (CRC)", "Bad Request", "Seek Error", "Unknown Media Type", "Sector Not Found", "Printer Out of Paper", " Write Fault "," Read Fault "," General Fault "," Reserved "," Reserved "," Invalid Disk change "}; error_win (char * msg) {int RetVal; CPUTS (MSG); / * Prompt for user to Press A Key To Abort, Retry, Ignore * / While (1) {RetVal = Getch (); if (Retval == 'A' || Retval == 'A') {RetVal = Abort; Break;} IF (RetVal == 'R' || RETVAL == 'R') {RETVAL = RETRY; Break;} if (Retval == 'I' || RetVal == 'I') {RetVal = Ignore; Break;}} Return ( Retval); SERRVAL, BP and Si to THE HANDLER. * / # Pragma Warn -Parint Handler (int {) {static char msg [80]; unsigned di; int drive; int erroorno; di = _Di; / * if this is not a disk error kilns ing * / if (ax <0) {/ * Report the error * / error_win ("device error"); / * and return to the program directly requesting Abort * / hardretn;} / * Otherwise it Was a disk error * / drive = AX & 0x00FF; erroorno = di & 0x00f;

/ * Report Which Error IT WAS * / SPRINTF (MSG, "Error:% S on DRIVE% C / R / NA) BORT, R) ETRY, / I) GNORE:", ERR_MSG [ErrorNo], 'A' Drive ); / * Return to the program via dos interrupt 0x23 with abort, retry, or ignore as input by the user. * / hardresume (error_win (msg)); Return Abort;} # Pragma Warn Parint Main (void) {/ * Install outmler on the hardware proBLerRupt * / Harderr (Handler); CLRSCR (); Printf ("Make Sure The Is No Disk In Drive A: / N"); Printf ("Press Any Key .... / N "); getCH (); Printf (" Trying to Access Drive A: / N "); Printf (" Fopen Returned% P / N ", FOPEN (" A: Temp.dat "," W "); Return 0 (}) Function name: HardResume function: hardware error handling function usage: void hardresume (int rescode); program: / * This Program Will Trap Disk Errors and prompt the userfor action. * // * Try Running It with no disk in drive A: to invoke itsfunctions * / # include #include #include #define ignore 0 # Define retry 1 # define abort 2int buf [500]; / * define the Error Messages for trapping disk problems * / static char * err_msg [] = {"Write Protect", "Unk NOWN UNIT "," DRIVE NOTY "," Data Error (CRC) "," Bad Request "," Seek Error "," Unknown Media Type "," Sector Not Found "," Printer Out of Paper "" Write Fault "," Read Fault "," General Failure "," Reserved "," Reserved "," Invalid Disk change "}; error_win (char * msg) {int RetVal; CPUTS (MSG); / * Prompt For user to press, ignore * / while (1) {retval = getch (); if (RetVal == 'A' || RetVal == 'a') {RetVal = Abort; Break;} IF (retval == 'r' || RetVal ==

'R') {RetVal = Retry; Break;} if (Retval == 'i' || RetVal == 'i') {RETVAL = Ignore; Break;}} Return (RetVal);} / * prgma warn -par Reduces Warnings Which Occur Due to Thenon Use * ///// ' 80]; Unsigned Di; Int Drive; Int ErrorNo; Di = _di; / * if this is not a disk error dam i as another devicehaving trouble * / if (ax <0) {/ * report the error * / error_win (" Device error "); / * and return to the program directlyrequesting abort * / hardretn (ABORT);} / * otherwise it was a disk error * / drive = ax & 0x00FF; errorno = di & 0x00FF; / * report which error it WAS * / SPRINTF (MSG, "Error:% S on DRIVE% C / R / NA) BORT, R) ETRY, / I) GNORE:", ERR_MSG [ERRORNO], 'A' Drive); / * Return TO the program via dos interrupt 0x23 with abort, retry or ignore as input by the user * / hardresume (error_win (msg));. return ABORT;} # pragma warn parint main (void) {/ * install our handler on the hardware Problem Interrupt * / Harderr (Handler); CLRSCR (); Printf ("Make Sure The No Disk In Drive A: / N"); Printf ("Press Any KEY .... / N"); getCh (); Printf "Trying to Access Drive A: / N"); Printf ("Fopen Returned% P / N", FOPEN ("A: Temp.dat", "W")); return 0;} function name: highvideo function: Select High-brightness text character usage: void highvideo (void); program case: #include int main (void) {clrs (); lowvideo (); cprintf ("low intensity text / r / n"); highvideo (); gotoxy (1, 2); CPRINTF ("High Intensity Text / R / N"); Return 0;} Function Name: Hypot Features: Calculating Right Rise Triangle Object Length Usage: Double Hypot (Double X, Double Y ); Example: #include #include

INT main (void) {Double Result; double x = 3.0; double y = 4.0; result = hypot (x, y); printf ("The Hypotenuse IS: LF / N", Result; Return 0;} letter i Opening Function Function Name: ImageSize Features: Returns the byte Number Use of Save Bit Images: Unsigned Far ImageSize (int include #include #include #include #include #include < Stdlib.h> #include #include #define arrow_size 10void Draw_arrow (int x, int y); int main (void) {/ * request autodtection * / int gDriver = detect, gmode, errorcode; void * arrow; int x, y, maxx; unsigned int size; / * 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 * /} maxx = getmaxx (); x = 0; y = getmaxy () / 2; / * draw_arrow (x, y); / * Calculate the size of the image * / size = imagesize (x, y-arrow_size, x (4 * ARROW_SIZE), y ARROW_SIZE); / * allocate memory to hold the image * / arrow = malloc (size); / * grab the image * / getimage (x, y-ARROW_SIZE, x (4 * ARROW_SIZE), y ARROW_SIZE , arrow); / * Repeat Until a key isperat * / while (! kbhit ()) {/ * Erase Old Image * / Putimage (x, y-arrow_size, arrow, xor_put); x = arrow_size; if (x > = maxx) x = 0; / * Plot new image * / putimage (x, y-arrow_size, arrow, xor_put);} / * clean up * / free (arrow); closegraph (); Return 0;} void Draw_arrow (int x, int y) {/ * draw an arrow on the screen * / moveto (x, y); LineRel (4 * arrow_size, 0); LineRel (-2 * arrow_size, -1 * arrow_size);

LineRel (0, 2 * arrow_size); LineRel (2 * arrow_size, -1 * arrow_size);} function name: INITGRAPH function: initialization graphics system usage: Void Far Initgraph (int Far * graphdriver, int far * graphmode, char far * Pathtodriver; program example: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = DETECT, gmode, errorcode; / * 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); / * return with error code * /} / * Draw a line * / line (0, 0, getmaxx (), getmaxy ()); / * Clean up * / getch (); closegraph (); return 0;} function name: Inport function: from hardware port Input usage: int database: #include #include int main (void) {int result; int port = 0; / * serial port 0 * / result = Inport (port); Printf ("Word Read From Port% D = 0x% x / n", port, result); Return 0;} function name: InSline function: Insert an air line usage in a text window: Void Insline (Void); program case: #include int main (void) {clrs (); CPrintf ("InSline Inserts an Empty Line in the text / window / R / N "); CPRINTF (" AT the cursor position using the current text // r / n "); CPRINTF (" Background Color. All Lines Below the Empty / One / R / N "); CPRINTF (" Move Down One line and the bottom line scrolls // r / n "); CPRINTF (" Off the bottom of the window./r/n" ";cprintf ("/r/npress any key to payue: "); gotoxy (1 , 3); Getch (); INSLINE (); getch (); return 0;} function name: installUserDriver function: Installation device driver to BGI device driver table Usage: int Far InstallUserDriver (Char far * name, int * Detect) (void));

Delivatives: #include #include #include #include / * function prototypes * / int huge detectega; void checkerrors (void); int main (void) {int gdriver, gmode; / * install a user written device driver * / gdriver = installuserdriver ( "EGA", detectEGA); / * must force use of detection routine * / gdriver = DETECT; / * check for any installation errors * / checkerrors (); / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * check for any initialization errors * / checkerrors (); / * draw a line * / line ( 0, 0, getmaxx (), getmaxy ()); / * clean up * / getch (); closegraph (); return 0;} / * detects ega or vga cards * / int huge detectega (void) {Int Driver, Mode, SugMode = 0; DetectGraph (& DRIVER, & MODE); if (DRIVER == EGA) || (DRIVER == VGA)) / * return suggested video mode number * / return sugmode; else / * return an error code * / RETURN GRERROR;} / * check for and report any graphics errors * / void checkerrors (void) {int errorcode; / * read result of last graphics operation * / ErrorCode = graphresult (); if (ERRORCODE! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key To Halt:"); getCh (); exit (1);}}} function name: InstallUserfont function: Font file (CHR) without embedding BGI system: Int Far InstallUserfont (Char Far * Name); program: #include #include #include #include / * function prototype * / void checkerrors (void); int main (void) {/ * request auto detection * / int gDriver = detect, gmode; int Userfont ; int MIDX, Midy; / * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, ""); midx = getmaxx () / 2; midy =

getmaxy () / 2; / * check for any initialization errors * / checkerrors (); / * install a user defined font file * / userfont = installuserfont ( "USER.CHR"); / * check for any installation errors * / checkerrors (); / * Select the user font * / setTextStyle (Userfont, Horiz_Dir, 4); / * Output Some Text * / Outtextxy (MIDX, Midy, "Testing!"); / * Clean Up * / getCh (); Closegraph (); return 0;} / * check for and report any graphics errors * / void checkerrors (void) {int errorcode; / * read result of last graphics operation * / errorcode = graphresult (); if (! errorcode = grOk) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1);}}}} function name: int86 function: General 8086 Soft Interrupt Interface Usage: INT INT86 (INT INTR_NUM, Union Regs * INREGS, Union Regs * Outregs); Arts: #include #include #include #define video 0x10void MoveToxy (int x, int y) {union regs regs; regs.h.ah = 2; / * set cursor post * / regs.h.d = Y; regs.h.dl = x; regs.h.bh = 0; / * Video Page 0 * / INT86 (Video, & Regs, & Regs);} int Main (void) {clrs CR (); MoveToxy (35, 10); Printf ("Hello / N"); return 0;} function name: int86x function: Universal 8086 Soft Interrupt Interface Usage: int rt86x (int INTR_NUM, Union Regs * INSEGS, Union Regs * Outregs, Struct Sregs * Segregs; program: #include #include #include int main (void) {char filename [80]; Union Regs INREGS, OUTREGS; Struct Sregs Segregs; Printf ("Enter filename:"); gets (filename); INREGS.H.AH = 0x43; INREGS.H.AL = 0x21; INREGS.X.DX = fp_off (filename) Segregs.ds = fp_seg (filename); INT86X (0x21, & INREGS, & OUTREGS, & Segregs); Printf ("File Attribute: x / n", outregs.x.cx); Return 0;

} Function name: INTDOS function: Universal DOS interface usage: int INTDOS (Union Regs * INREGS, Union Regs * outregs); program: #include #include / * deletes file name; returns 0 on success, nonzero on failure * / int delete_file (char Near * filename) {UNION regs regs; int RET; regs.h.ah = 0x41; / * delete file * / regs.x.dx = (unsigned) FILENAME RET = INTDOS (& Regs, & Regs); / * if carry flag is set, there is an error * / return (regs.x.cflag? RET: 0);} int main (void) {int err; err = delete_file "NOTEXIST. $$$"); if (! ERR) Printf ("Able to delete Notexist. $$ / n"); ElsePrintf ("Not Able To Delete Notexist. $$ / N"); Return 0; } Function Name: INTDOSX Function: Universal DOS Interrupt Interface Usage: Int INTDOSX (Union Regs * INREGS, Union Regs * Outregs, Struct Sregs * Segregs); Series: #include #include / * deletes file name; returns 0 on success, nonzeroon failure * / int delete_file (char far * filename) {union regs regs; struct Sregs Sregs; int RET; regs.h.ah = 0x41; / * delete file * / regs. x.dx = fp_off (filename); Sregs.ds = fp_seg (filename); RET = INTDOSX (& Regs, & Regs, & Sregs ); / * if carry flag is set, there is an error * / return (regs.x.cflag? RET: 0);} int main (void) {int err; err = delete_file ("NOTEXIST. $$$" ); if (! ERR) PRINTF ("Aable to delete Notexist. $$ / n"); ElsePrintf ("Not Able To Delete Notexist. $$ / N"); Return 0;} Function Name: INTR function: Change Soft Interrupt Interface Usage: Void INTR (int INTR_NUM, STRUCT REGPACK * PREG); program: #include #include #include #include # Define cf 1 / * carry flag * / int main (void) {Char Directory [80]; Struct Regpack REG; Printf ("Enter Directory to change to:"); gets (directory); reg.r_ax = 0x3b << 8 ;

/ * SHIFT 3BH INTO AH * / REG.R_DX = fp_off (Directory); REG.R_DS = fp_seg (Directory); INTR (0x21, & Reg); if (REG.R_FLAGS & CF) Printf ("Directory Change Failed / N" Getcwd (Directory, 80); Printf ("THE CURRENT DIRECTORY IS:% S / N", Directory; Return 0;} function name: IOCTL function: Control I / O device usage: int ioctl (int Handle, INT CMD [, int * argdx, int argcx]); program example: #include #include #include int main (void) {int stat; / * USE FUNC 8 To DETERMINE IF The Default Drive Isremovable * / Stat = IOCTL (0, 8, 0, 0); if (! Stat) Printf ("Drive% C Is Removable./N", getDisk () 'A'); Elseprintf ("DRIVE% C Is Not Removable./n", GetDisk() 'a'a );Return 0;} function name: isatty function: Check device type usage: int isatty (int Handle); program: #include < Stdio.h> #include int main (void) {int Handle; Handle = fileno (stdprn); if (isatty (Handle) Printf ("Handle% D Is A Device Type / N", Handle) ElsePrintf ("Handle% D isn't a device type / n", handle); return 0;} function name: ITOA function: convert an integer into character string: char * itoa (int value, char * String, Int radix; program: #include #include int main (void) {int Number = 12345; char string [25]; ITOA (Number, String, 10); Printf ("Integer =% D String =% S / N", Number, String); Return 0; } Letter K start function function name: KBHIT function: Check the currently pressed key method: int kbhit (void); program case: #include int main (void) {CPRINTF ("Press Any Key to Continue: "); While (! kbhit ()) / * do nothing * /; cprintf (" / r / na key was press ... / r / n "); return 0;} function name: Keep function: Exit and continue Resident usage: void Keep (int status, int size);

Program Example: / *** NOTE:.. This is an interrupt service routine Youcan NOT compile this program with TestStack Overflow turned on and get anexecutable file which will operatecorrectly Due to the nature of thisfunction the formula used to computethe number of paragraphs may notnecessarily work in all cases. Use withcare! Terminate Stay Resident (TSR) programs are complex and no other supportfor them is provided. Refer to theMS-DOS technical documentationfor more information. * / # include / * The clock tick interrupt * / # define INTR 0x1C / * Screen attribute (blue on grey) * / # define ATTR 0x7900 / * reduce heaplength and stacklengthto make a smaller program in memory * / extern unsigned _heaplen = 1024; extern unsigned _stklen = 512; void interrupt ( * OldHandler (void); Void Interrupt Handler (Void) {Unsigned Int (Far * Screen) [80]; Static Int Count; / * for a Color Screen The Video Memoryis AT B800: 0000. for a monochromesystem use b000: 000 * / screen = mk_fp (0xB800, 0); / * Increase the counter and keep itwithin 0 t O 9 * / count ; count% = 10; / * put the number on the screen * / screen [0] [79] = count '0' attr; / * call the old interrupt handler * / oldhandler (); } int main (void) {/ * get the address of the current clocktick interrupt * / oldhandler = getvect (INTR); / * install the new interrupt handler * / setvect (INTR, handler); / * _psp is the starting address of ... theprogram in memory The top of the stackis the end of the program Using _SS and_SP together we can get the end of thestack You may want to allow a bit of saftey space to insure that enough roomis being allocated ie: (_ SS ( (_SP Safety Space) / 16) - _PSP) * / Keep (0, (_ss (_SP / 16) - _PSP)); Return 0;} letter L

Opening function function name: LABS function: Take a long integer absolute value: long labs (long n); program: #include #include int main (void) {long result; long X = -12345678L; Result = labs (x); Printf ("Number:% LD ABS Value:% LD / N", X, Result); Return 0;} function name: LDEXP function: Calculate Value * 2 power usage : Double LDEXP (Double Value, Int Exp); Questions: #include #include int main (void) {double value; double x = 2; / * LDEXP RAISES 2 by a Power Of 3Then Multiplies The Result By 2 * / Value = LDEXP (X, 3); Printf ("The LdexP Value IS:% LF / N", Value); Return 0;} Function Name: LDIV Function: Two Long Integer Number, return business and expensive usage: LDIV_T LDIV (long lnumer, long ldenom); program example: / * ldiv example * / # include #include int main (void) {LDIV_T LX; lx = ldiv (100000L, 30000L); Printf ("100000 Div 30000 =% ld Remainder% LD / N", LX.quot, Lx.Rem); Return 0;} function name: LFIND function: Perform linear search usage : void * LFIND (Void * Key, Void * Base, INT * NELEM, INT Width, INT (* fcmp) ()); program example: #include #include int ComPare * x, int * y) {RETURN (* x - * y);} int main (void) {int Array [5] = {35, 87, 46, 99, 12}; SIZ E_T NELEM = 5; int key; int * result; key = 99; Result = LFIND (& Key, Array, & Nlem, SizeOf (int), (int) (int)) Compare; if ("Number% D found / n", key); ElsePrintf ("Number% D Not Found / N", Key); Return 0;} Function Name: Line Function: Painting in the designated two points Usage: Void Far Line (int X0, int y0, int x1, int y1); example: #include #include #include #include INT Main (void) {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; INT XMAX, YMAX; / * Initialize Graphics and Local Variables * / Initgraph (& gdriver, & gmode, "");

/ * read results = graphresult (); / * an error occurred * / if (erroorcode! = grok) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); setcolor (); xmax = getmaxx (); ymax = getMaxy (); / * draw a diagonal line * / line (0, 0, xmax, ymax); / * clean up * / getch (); closegraph (); return 0;} function name: LineRel function: from the current location point (CP) to the CP with a given distance of a point-to-distance Usage: Void Far LineRel (INT DX, INT DY); Questions: #include #include #include #include int main (void) { / * request auto detection * / int gdriver = DETECT, gmode, errorcode; char msg [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphResult (); if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1 );} / * Move the cp to location (20, 30) * / MoveTo (20, 30); / * Create and Output Amessage At (20, 30) * / SPRI NTF (MSG, "(% D,% D)", getX (), getY ()); Outtextxy (20, 30, msg); / * Draw a line to a point a relativedistance awful from the currentValue of CP * / LineRel (100, 100); / * CREATE AND OUTPUT A Message AT CP * / Sprintf (MSG, "(% D,% D)", getX (), getY ()); OutText (msg); / * Clean Up * / getch (); closegraph (); return 0;} function name: localtime function: Transform date and time into structural usage: struct TM * localtime (long * clock); program: #include # INCLUDE #include int main (void) {time_t timer; struct tm * tblock; / * gets time of day * / time = time (null); / * Converts Date / Time TO A Structure * / tblock = localtime (& Timer); Printf ("

LOCAL TIME IS:% S ", Asctime (TBLOCK)); Return 0;} function name: LOCK function: Settings file shared lock usage: int Lock (Int Handle, long offset, long length); program case: #include #include #include #include #include #include int main (void) {Int Handle, Status Long longth; / * must harness dos share.exe loaded for * /// * file locking to function protection = Sopen ("c: //autoexec.bat", o_rdonly, sh_denyno, s_iread; if (Handle < 0) {Printf ("Sopen FaileD / N"); exit (1);} length = filelength; status = lock (handle, 0l, length / 2); if (status == 0) Printf ("LOCK Succeeded / N "); ElsePrintf (" Lock Failed / N "); status = unlock (Handle, 0L, Length / 2); if (status == 0) Printf (" unlock succeed / n "); Elseprintf (" unlock Failed / n "); Close (Handle); Return 0;} function name: log function: logarithmic function ln (x) Usage: double log (double x); program: #include #include < Stdio.h> int main (void) {Double Result; double x = 8.6872; result = log (x); Printf ("The Natural Log of% LF IS% LF / N", X, Result); Return 0;} Function name: log10 function: logarithm function log usage: double L OG10 (Double X); Question: #include #include int main (void) {Double Result; double x = 800.6872; result = log10 (x); printf ("THE COMMON LOG) Of% LF IS% LF / N ", X, Result); Return 0;} function name: longjump function: Perform non-local transfer usage: void longjump (jmp_buf env, int val); program case: #include #include #include void subs (jmp_buf); int main (void) {int value; jmp_buf jumper; value = setjmp (jumper); if (value! = 0) {Printf "Longjmp with value% d / n", value); exit (value); "About to call subroutine ... / n");

Subroutine; Return 0;} void subsin (jmp_buf jumper) {longjmp (jumper, 1);} function name: lowvideo function: Select low brightness character usage: Void LowVideo (void); program case: #include int main (void) {clrs (); highvideo (); cprintf ("high intesis text / r / n"); lowvideo (); gotoxy (1, 2); cprintf ("low intensity text / r / n "); return 0;} function name: lrotl, _lrotl function: unsigned long-intensive number to left loop shift usage: unsigned long lvalue, int count; unsigned long _lrotl (unsigned long Lvalue, int Count; / * Lrotl Example * / # include #include int main (void) {unsigned long result; unsigned long value = 100; Result = _lrotl (value, 1) Printf ("The Value% Lu Rotated Left One Bit IS:% Lu Rotated Left One Bit IS:% Lu / N", Value, Result); Return 0;}> LSEARCH Function: Linear Search Usage: Void * LSearch (const void * key, void * Base, size_t * nlem, size_t width, int (* fcmp) (const void *, const void *); program example: #include #include int compare (int * x, int * x, int * x, int * Y) {RETURN (* x - * y);} int main (void) {Int Array [5] = {35, 87, 46, 99, 12}; size_t nlem = 5; int key; int * result; Key = 99; result = LFIND (& Key, Array, & Nlem, Sizeof (int), (int (*) (const void *, const void *) compare); if (Result) Printf ("Number% D Found / N", Key); ElsePrintf ("Number% D Not Found / N", Key); Return 0;} function name: LSeek function: mobile file read / write pointer usage: Long Lseek (int Handle, Long Offset, Int fromwhere); Include #include #include #include #include int main (void) {Int Handle; char msg [] = "This is a test"; char ch; / * Create a file * / hand = open ("Test. $$$", 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 untric we hit eof * / do {read (Handle, & Ch, 1); Printf ("% C" ,} while (! EOF (Handle); close (Handle); Return 0;} Letter m start function function name: Malloc function: Memory allocation function usage: void * malloc (unsigned size); program: # Include #include #include #include int main (void) {char * str; / * allocate memory for string * // * this will generate An error when compling * // * with c , use the new operator instead. * / if ((Str = Malloc (10)) == null) {Printf ("Not Enough Memory To Allocate Buffer / N); EXIT 1); / * Terminate Program if out of memory * /} / * Copy "Hello" INTO STRING * / STRCPY (STR, "Hello"); / * Display string * / printf ("string IS% S / N", Str); / * free memory * / free (str);} function name: Matherr function: User-modified mathematical error handler usage: int match (Struct Exception * e); program: / * this is IS a user-defined Matherr Function That PreventSany Error Messages from Being Printed. * / # include int match 1;} function name : Memccpy Features: Copy n bytes from Source Source to Target Destin: Void * Memccpy (Void * Destin, Void * Source, unsigned char ch, unsigned n); program: #include # Include int main (void) {char * src = "this is the source string"; char DEST [50]; char * ptr; ptr = Memcpy (DEST, SRC, 'C', Strlen (src) ); if (ptr) {* PTR = '/ 0'; Printf ("THE Character Was Found:% S / N", DEST);} elseprintf ("The Character Wasn't Found / N); Return 0; } Function name: Memchr function: Search character usage in the first n byte of the array: Void * Memchr (void * s, char ch, unsigned n); program: #include #include int main (void) {char str [17]; char * PTR;

STRCPY (STR, "this is a string"); PTR = Memchr (STR, 'R', Strlen (STR)); if (PTR) Printf ("The Character 'R' Is At Position:% D / N", PTR - STR); ElsePrintf ("THE Character Was Not Found / N"); Return 0;} Function Name: Memcpy Features: Copy N bytes from Source Source to Target Destin: Void * Memcpy (Void * Destin , void * source, unsigned n); program example: #include #include int main (void) {char src [] = "*********** ****************** "; char des [] =" AbcdefghijlkmnopqrStuvwxyz0123456709 "; char * ptr; Printf (" Destination Before Memcpy:% S / N ", DEST); PTR = Memcpy (DEST, SRC, STRLEN (SRC)); IF (PTR) Printf ("Destination After Memcpy:% S / N", DEST); ElsePrintf ("Memcpy Failed / N"); Return 0;} Function Name: MemicMP function: Compare the front n bytes of both strings S1 and S2, ignore case-by-case use: int MemicMP (Void * S1, Void * S2, Unsigned N); program case: #include #include < String.h> int main (void) {char * buf1 = "abcde123"; char * buf2 = "abcde456"; int stat; stat = memicmp (buf1, buf2, 5); printf ("The strings to position 5 are" ); if (stat) Printf ("not"); Printf ("THE SAME / N"); Return 0;} function name: Memmove function: Mobile a byte usage: void * MEMM Ove (Void * Destin, Void * Source, Unsigned N); Procedure: #include #include int main (void) {char * dest = "AbcdefghijklmnopqrStuvwxyz0123456789"; char * src = " ******************************* "; Printf (" Destination Prior to Memmove:% S / N ", DEST); MEMMOVE (DEST, SRC, 26); Printf ("Destination After Memmove:% S / N", DEST); RETURN 0;} Function Name: MEMSET Function: Set all bytes in S to CH, s array size by N For the usage: Void * Memset (Void * S, Char ch, unsigned n); example: #include #include #include int main (void) {char Buffer [] =

"Hello World / N"; Printf ("Buffer Before Memset:% S / N", Buffer; MEMSET (Buffer, '*', Strlen (Buffer) - 1); Printf ("Buffer After Memset:% S / N ", buffer); RETURN 0;} function name: MKDIR function: Create a directory usage: int mkdir (char * pathname); program: #include #include #include #include int main (void) {int stat (= mkdir); (! status)? ("Directory Created / N"): (Printf): (Printf ("Unable to create Directory / N))); getCH (); system (" dir "); getch (); status = rmdir (" asdfjklm "); (! Status)? (Printf (" Directory deleted / N " ): ("Unable to delete Directory)); Return 0;} function name: MkTemp function: Establish a unique file name usage: char * mktemp (char * template); program: #include #include int main (void) {/ * fname defines the template for the Temport file. * / char * fname = "txxxxxx", * PTR; PTR = mktemp (fname); Printf ("% s / N ", PTR); RETURN 0;} function name: MK_FP function: Set a remote pointer method: Void Far * mk_fp (unsigned seg, unsigned off); example: #include #include int main (void) {INT GD, GM, I; Unsigned Int Far * Screen DetectGraph (& gd, & gm); if (gd == Hercmono) Screen = mk_fp (0xB000, 0); Elsescreen = MK_FP (0xB800, 0); for (i = 0; i <26; i ) screen [i] = 0x0700 ('a' i); Return 0;} function name: MODF function: divide the number into an index and masonry usage: double modf (double value, double * iptr); program: #include # INCLUDE int main (void) {Double Fraction, Integer; Double Number = 100000.567; Fraction = Modf (Number, & Integer); Printf ("The Whole and Fractional Parts OF% LF Are% LF / AND% LF / N ", Number, Integer, FRACTION; RETURN 0;

} Function name: MoveData function: copy byte usage: Void MoveData (int SEGSRC, INT OFFSRC, INT SEGDEST, INT OFFDEST, Unsigned NumBytes); Questions: #include #define mono_base 0xB000 / * SAVES THE Contents Of the monochrome screen in buffer * / void save_mono_screen (char near * buffer) {movedata (mono_base, 0, _ds, (unsigned) buffer, 80 * 25 * 2);} int main (void) {charf [80 * 25 * 2]; save_mono_screen (buf);} function name: MoveRel function: Move the current location (CP) to a relative distance usage: Void Far MoveRel (int DX, int DY); program: #include # Include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; char msg [80]; / * 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 * /} / * Move THE CP To Location (20, 30) * / MoveTo (20, 30); / * Plot a Pixel at the cp * / putpixel (getX (), gety (), getmaxcolor ()); / * CREATE AND OUTPUT A Message At (20, 30) * / Sprintf (MSG, "(% D,% d) ", getX (), getY ()); Outtextxy (20, 30, msg); / * Move to a point a relative distance * // * Away from the current value of cp * / moverel (100, 100) ; / * Plot a Pixel at the cp * / putpixel (getX (), gety (), getmaxcolor ()); / * CREATE AND OUTPUT A Message AT CP * / Sprintf (MSG, "(% D,% D)" , getX (), getY (); OUTTEXT (MSG); / * clean up * / getch (); closegraph (); return 0;} function name: MoveText function: copy screen text from a rectangular area to another Rectangular area usage: int MoveText (int LEFT, INT TOP, INT RIGHT, INT BOTTOM, INT NEWLEFT, INT NEWTOP);

#include int main (void) {char * str = "this is a test string"; CLRSCR (); cPUTS (STR); getCh (); MoveText (1, 1, strs), 2 , 10, 10); Getch (); RETURN 0;} function name: MoveTo function: Move CP to (x, y) Usage: Void Far Moveto (INT X, INT Y); program case: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; char msg [80] ; / * 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 * /} / * Move the cp to location (20, 30) * / MoveTo (20, 30); / * Plot a Pixel at the cp * / putpixel (getX (), getY (), getmaxcolor ()); / * CREATE AND OUTPUT A Message At (20, 30) * / SPRINTF (MSG, "(% D,% D)", getX (), getY ()); OutTextxy (20, 30, msg); / * Move To (100, 100) * / MoveTo (100, 100); / * Plot a Pixel at the cp * / putpixel (getX (), gety (), getmaxcolor ()); / * CREATE AND OUTPUT A Message AT CP * / Sprintf (MSG, "(% D,% D ), getX (), gety (); outtext (msg); / * clean up * / getch (); closegraph (); return 0;} function name: MoveMem function: Mobile a byte usage: void MoveMem Void * Source, Void * Destin, Unsigned Len; program: #include #include #include #include int main (void) {char * source = "borland international"; char * destination; intlene; length = strlen (Source); destination = malloc (length 1); MOVMEM (Source, Destination, Length); Printf ("% s / n", Destination RETURN 0;

} Letter N start function function name: NormVideo function: Select normal brightness character usage: void normvideo (void); program case: #include int main (void) {normvideo (); CPrintf ("Normal Intensity Text / R / N "); RETURN 0;} function name: NOSOSOSID function: Turn off PC speaker usage: void noid (void); program case: / * Emits a 7-hz Tone for 10 Seconds. True Story: 7 HZ is the Resonant . frequency of achicken's skull cavity This was determined empiricallyin Australia, where a new factory generating 7-Hz toneswas located too close to a chicken ranch:. When thefactory started up, all the chickens died Your PC may not be able to emit a 7- Hz Tone. * / Int main (void) {Sound (7); DELAY ();} letter (} letter O start function): Open function: Open a file for reading or writing: int open (charr * Pathname, int access [, int permiss];: #include #include #include #include int main (void) {INT Handle; char msg [] = "Hello World"; if ("Test. $$$", o_creat | o_text)) == -1) {PERROR ("Error:"); Return 1;} Write (Handle, MSG, Strlen (MSG)); Close (Handle); Return 0;} Function Name: Outport Features: Output Integer to Hardware Port Usage: Void Outport (Int Port, i NT value); program example: #include #include int main (void) {int value = 64; int port = 0; OUTPORTB (Port, Value); Printf ("Value% D Sent to Port Number% D / N ", Value, Port); Return 0;} function name: OutportB function: Output byte to hardware port Usage: Void Outportb (int port, char Byte); program: #include < Stdio.h> #include int main (void) {int value = 64; int port = 0; OUTPORTB (Port, Value); Printf ("Value% D Sent to Port Number% D / N", Value, port); RETURN 0;} function name: OutText function: display a character string in the view: Void Far Outtext (Char far * text "; program: #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; / * move the cp to the center of the center of the center Screen * / MoveTo (Midx, Midy); / * Output text starting at the cp * / outtext ("this"); OutText ("IS"); OUTTEXT ("a"); OutText ("Test."); / * Clean Up * / getch (); closegraph (); return 0;} function name: OutTextxy function: display a series of string using: Void Far Outtextxy (int x, int y, char * textstring); #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode INT MIDX, MIDY; / * Initialize Graphics and Local Variables * / Initg Raph (GDriver, & gmode, ""); / * read result = graphresult (); if (errorcode! = GROK) / * an error occurred * / {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; / * Output text at the center of the screen * /// * Note: The cp doesn't get change. * / Outtextxy (MIDX, MIDY, "this is a test."); / * Clean Up * / getch (); closegraph (); return 0;} letter P

Opening function function name: PARSFNM function: Analysis file name usage: char * PARSFNM (Char * cmdline, intent fcb * fcbptr, int option); program: #include #include #include < Stdio.h> #include int main (void) {char line [80]; struct fcb blk; / * get file name * / printf ("Enter Drive and file name (no path - ie. / a : file.dat) / n "); gets (line); / * Put file name in FCB * / IF (PARSFNM (Line, & BLK, 1) == NULL) Printf (" Error In Parsfm Call / N "); ElsePrintf ("DRIVE #% D Name:% 11S / N", BLK.FCB_DRIVE, BLK.FCB_NAME); RETURN 0;} Function Name: PEEK Function: Check storage unit usage: int peek (int segment, unsigned offset); program Example: #include #include #include int main (void) {int value = 0; Printf ("The current status of your keyboard is: / n"); Value = peek (0x0040, 0x0017); if (Value & 1) Printf ("Right Shift ON / N"); ElsePrintf ("Right Shift Off / N"); if (Value & 2) Printf ("Left Shift ON / N "); ElsePrintf (" LEFT SHIFT OFF / N "); if (Value & 4) Printf (" Control Key ON / N "); ElsePrintf (" Control Key Off / N "); if (Value & 8) Printf ("Alt Key ON / N"); ElsePrintf ("alt key off / n"); i f (Value & 16) Printf ("scroll lock N / N"); ElsePrintf ("scroll lock off / n"); if (Value & 32) Printf ("Num Lock ON / N"); Elseprintf ("Num Lock OFF / N "); if (Value & 64) Printf (" Caps Lock ON / N "); ElsePrintf (" Caps Lock Off / N "); Return 0;} Function Name: Peekb Features: Check storage unit usage: char PEEKB (Int Segment, Unsigned Offset); Questions: #include #include #include int main (void) {int value = 0; Printf ("THE CURRENT STATUS Of your keyboard is: / n "); value = peekb (0x0040, 0x0017); if (Value &

1) Printf ("Right Shift ON / N"); ElsePrintf ("Right Shift Off / N"); if (Value & 2) Printf ("Left Shift ON / N"); ElsePrintf ("Left Shift Off / N" ); if (Value & 4) Printf ("Control Key ON / N"); ElsePrintf ("Control Key Off / N"); if (Value & 8) Printf ("Alt Key ON / N"); ElsePrintf (" Alt key off / n "); if (Value & 16) Printf (" scroll lock N / n "); ElsePrintf (" scroll lock off / n "); if (Value & 32) Printf (" Num Lock ON / N) "); ElsePrintf (" Num Lock Off / N "); if (Value & 64) Printf (" Caps Lock ON / N "); ElsePrintf (" Caps Lock Off / N "); Return 0;} Function Name: PERROR Function: System error information usage: void perror (char * string); program case: #include int main (void) {file * fp; fp = fopen ("PERROR.DAT", "R"); If (! fp); Return 0;} function name: pieslice feature: Draw and populate a fan-shaped usage: Void Far Piemelice (int X, int Stanle, int endangle, int RADIUS) : #Include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, Gmode, ErrorCode; Int Midx, Midy; Int Stangle = 45, Endangle = 135, R adius = 100; / * 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; / * set Fill Style and Draw A PIE SLICE * / setFillStyle (Empty_Fill, getmaxcolor ());

Piemelice (MIDX, Midy, Stangle, Endangle, Radius); / * Clean Up * / Getch (); Closegraph (); Return 0;} Function Name: Poke Features: To a given storage unit usage: void poke Int segment, int offset, int value); program example: #include #include int main (void) {clrs (); CPrintf ("Make Sure Scroll Lock Key Is Off and Press / any key / r / n "); getCH (); poke (0x0000, 0x0417, 16); CPRINTF (" THE SCROLL LOCK IS NOW ON / R / N "); Return 0;} function name: Pokeb function: save Value to a given storage unit usage: Void pokeb (int segment, int offset, char value); program example: #include #include int main (void) {clrs CRSCR (); CPrintf ("Make Sure The Scroll Lock Key IS Off and Press / any Key / R / N"); getCh (); pokeb (0x0000, 0x0417, 16); CPRINTF ("THE SCROLL LOCK IS NOW ON / R / N") Return 0;} function name: POLY function: Generate a polynomial usage based on parameters: Double Poly (Double X, INT N, Double C []); program case: #include #include / * POLYNOMIAL: X ** 3 - 2X ** 2 5X - 1 * / int main (void) {Double Array [] = {-1.0, 5.0, -2.0, 1.0}; Double Result; Result = Poly (2.0 , 3, array); Printf ("The Polynomial: x ** 3 - 2.0x ** 2 5X - 1 AT 2.0 / I% LF / N", Result RETURN 0;} function name: POW function: Index function (x Y times) Usage: Double Pow (double x, double y); program: #include #include INT main (void) {double x = 2.0, y = 3.0; Printf ("% lf raised to% LF IS% LF / N", X, Y, POW (X, Y)); Return 0;} function name: POW10 function: Index function (10 P movable) Usage: Double Pow10 (INT P); program: #include #include int main (void) {double p = 3.0; printf ("Ten Raised TO% LF IS% LF / N", P, POW10 (P)); RETURN 0;} function name: Printf function: Function usage of formatted output: int printf (char * format ...) Draft: #include #include #define i 555 # define r 5.5INT main (void) {INT I, J, K, L; Char BUF [7]; char * prefix = BUF;

Char TP [20]; Printf ("PREFIX 6D 6O 8X 10.2e" "10.2F / N"); STRCPY (prefix, "%"); for (i = 0; i <2; i ) {for (j = 0; j <2; j ) for (k = 0; k <2; k ) for (l = 0; l <2; l ) {if (i == 0) STRCAT (prefix, "-"); if (j == 0) STRCAT (Prefix, " "); if (k == 0) strcat (prefix, "#"); if (l == 0) STRCAT (Prefix, "0"); Printf (" % 5s | ", Prefix; STRCPY (TP, Prefix); STRCAT (TP," 6D | "); Printf (TP, I); STRCPY (TP,"); STRCPY (TP, prefix); strcat , "6o |"); Printf (TP, I); STRCPY (TP, "); STRCPY (TP, Prefix); STRCAT (TP," 8x | "); Printf (TP, I); STRCPY (TP, ""); strcpy (TP, prefix); strcat (TP, "10.2e |"); Printf (TP, R); STRCPY (TP, Prefix); STRCAT (TP, "10.2F |"); Printf (TP , R); Printf ("/ n"); strcpy (prefix, "%");}} return 0;} function name: PUTC function: Output a character to the specified stream Usage: int PUTC (int CH, file * Street: #include int main (void) {char msg [] = "Hello World / N"; int i = 0; while (MSG [i]) PUTC (MSG [i ], STDOTOT); RETURN 0;} function name: PUTCH function: Output characters to control desktics: int Putch (int CH); program: #include #include int main (void) { CHAR CH = 0; Printf ("INPUT A String:"); while ((ch! = '/ r')) {ch = g ETCH (); PUTCH (CH);} Return 0;} function name: PUTCHAR function: Output character usage on Stdout: int Putchar (int CH); program case: #include / * define Some Box- drawing characters * / # define LEFT_TOP 0xDA # define RIGHT_TOP 0xBF # define HORIZ 0xC4 # define VERT 0xB3 # define LEFT_BOT 0xC0 # define RIGHT_BOT 0xD9int main (void) {char i, j; / * draw the top of the box * / putchar ( LEFT_TOP); for (i = 0; i <10; i ) Putchar (Horiz); PUTCHAR (Right_Top); Putchar ('/ n');

/ * DRAW THE MIDDLE * / for (i = 0; i <4; i ) {PUTCHAR (VERT); for (j = 0; j <10; j ) Putchar (''); PUTCHAR (VERT); PUTCHAR '/ n');} / * Draw the bottom * / putchar (left_bot); for (i = 0; i <10; i ) Putchar (horiz); PUTCHAR (Right_Bot); PUTCHAR ('/ n'); Return 0;} function name: Putenv function: add string to the current environment: int Putenv (Char * Envvar); program: #include #include #include #include #include int main (void) {char * path, * ptr; int i = 0; / * get the current path environment * / ptr = getenv ("path") ; / * SET UP new path * / path = malloc (Strlen (PTR) 15); STRCPY (PATH, "PATH ="); strcat (PTH, PTR); strcat (path, "; c: // Temp" ); / * Replace the current path and display currenvironment * / putenv (path); while (Environment [i]) Printf ("% s / n", Environ [i ]); Return 0;} function name: PUTIMAGE function: Output a bitmap method on the screen: Void Far Putimage (INT X, INT Y, VOID FAR * BITMAP, INT OP); program example: #include #include #include #include #define arrow_size 10void draw_arrow (int x, int y); int main (void) {/ * request autodtection * / Int gdriver = DETECT, gmode, errorcode; void * arrow; int x, y, maxx; unsigned int size; / * 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 * /} maxX = getmaxx (); x = 0; y = getmaxy () / 2; / * draw the image to be grabbed * / DRAW_ARROW (X, Y);

/ * Calculate the size of the image * / size = imagesize (x, y-arrow_size, x (4 * arrow_size), y arrow_size); / * allocate memory to hold the image * / arrow = malloc (size); / * Grab the Image * / GetImage (x, y-arrow_size, x (4 * arrow_size), y arrow_size, arrow); / * Repeat Until a key is presssed * / while (! kbhit ()) {/ * ERASE OLD Image * / putimage (x, y-arrow_size, arrow, xor_put); x = arrow_size; if (x> = maxx) x = 0; / * Plot new image * / putimage (x, y-arrow_size, arrow, xor_put );} / * clean Up * / free (arrow); closegraph (); return 0;} void draw_arrow (int x, int y) {/ * draw an arrow on the screen * / moveto (x, y); lineRel (4 * arrow_size, 0); LineRel (-2 * arrow_size, -1 * arrow_size); LineRel (0, 2 * arrow_size); LineRel (2 * arrow_size, -1 * arrow_size);} Function Name: PUTPIEL function: in Specify position drawing a pixel usage: Void Far Putpixel (int X, int y, int pixelcolor); program: #include #include #include #include #include #define pixel_count 1000 # define delay_time 100 / * in MilliseConds * / int main (void) {/ * Request Autodetecti ON * / INT GDRIVER = DETECT, GMODE, ERRORCODE; INT i, X, Y, Color, Maxx, Maxy, MaxColor, Seed; / * 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 * /} maxx = getmaxx () 1; maxy = getMaxy () 1; maxColor = getMaxcolor () 1; While (! kbhit ()) {/ * seeded = random (32767); srand (seed); for (i = 0; i <

Pixel_count; i ) {x = random (MAXX); Y = Random (MAXY); Color = Random (MaxColor); PUTPIEL (X, Y, Color);} delay (delay_time); SRAND (SEED); for (i = 0; I int main (void) {char string [] = "this is an example output string / n"; PUTS (String); Return 0;} function name: PUTTEXT function: copy text from the storage area to the screen usage : Int PutText (int LEFT, INT TOP, INT RIGHT, INT BOTTOM, VOID * SOURCE); Procedure: #include int main (void) {char buffer [512]; / * Put Some text to the THE Console * / clrs (); gotoxy (20, 12); CPRINTF ("this is a test. press any key to turnue ..."); getch (); / * grab screen contents * / getText (20, 12, 36, 21, buffer; clrs (); / * put successd characters back to the screen * / gotoxy (20, 12); PUTTEXT (20, 12, 36, 21, buffer); getch (); return 0;} Function Name: PUTW function: Send a character or word to the stream: int Putw (int W, File * Strea m);: #include #include #define fname "test. $$$" int main (void) {file * fp; int word; / * Place the Word IN A File * / fp = fopen (FNAME, "WB"); if (fp == null) {Printf ("Error Opening File% S / N", FNAME); Exit (1);} Word = 94; PUTW (Word , FP); if ("Error Writing to File / N"; ElsePrintf ("Successful Write / N"); Fclose (FP); / * Reopen THE File * / FP = FOPEN (FNAME , "RB"); if (fp == null) {Printf ("Error Opening File% S / N", FNAME); EXIT (1);} / * extract the word * / word = getw (fp); if (FERROR (FP)) Printf ("Error Reading File / N"); Elseprintf ("

Successful read: Word =% D / N ", Word); / * clean up * / fclose (fp); unlink (fname); Return 0;} letter Q start function function name: QSORT function: using fast sort routines Sort Usage: Void Qsort (Void * Base, INT NELEM, INT Width, INT (* FCMP) ()); program example: #include #include #include int Sort_function (const void * a, const void * b); char List [5] [4] = {"CAT", "car", "cab", "cap", "can"}; int main (void) { INT X; QSORT (Void *) List, 5, SIZEOF (List [0]), sort_function; for (x = 0; x <5; x ) Printf ("% s / n", list [x]) }} int sort_function (const void * a, const void * b) {return (strcmp (a, b));} letter R start function function name: Raise function: Send a signal usage to the executable program: INT RAISE (INT SIG); #include int main (void) {Int a, b; a = 10; b = 0; if (b == 0) / * preempt Divide by Zero Error * / ras (SIGFPE); A = a / b; return 0;} function name: RAND function: Random number generator usage: Void Rand (Void); program case: #include #include int main (void) {INT I; Printf ("Ten Random Numbers from 0 to 99 / N / N"); for (i = 0; I <10; i ) Printf ("% D / N", RAND ()% 100); RETURN 0;} function name: RANDBRD function: random block Reading: int R Andbrd (struct fcb * fcbptr, int RECCNT); program example: #include #include #include #include int main (void) {Char Far * save_dta; char line [80], buffer [256]; struct fcb blk; int i, result; / * Get user input file name for dta * / printf ("Enter Drive and file name (no path - ie / a: File.dat) / n "); gets (line); / * Put file name in fcb * / if (! PARSFNM (Line, & BLK, 1)) {Printf (" Error In Call to Parsfnm / N); EXIT (1);} Printf ("DRIVE #% D File:% S / N / N", BLK.FCB_DRIVE, BLK.FCB_NAME);

/ * Open file with dos fcb open file * / bdosptr (0x0f, & blk, 0); / * save Old DTA, and set new one * / save_dta = getdta (); setdta (buffer); / * set up info for the New DTA * / BLK.FCB_RECSIZE = 128; BLK.FCB_Random = 0L; Result = Randbrd (& BLK, 1); / * Check Results from Randbrd * / if (! Result) Printf ("Read OK / N / N"); Else {Perror ("Error During Read"); EXIT (1);} / * Read in Data from the New DTA * / Printf ("THE FIRST 128 Characters Are: / N"); for (i = 0; i < 128; i ) PUTCHAR (Buffer [i]); / * restore previous DTA * / setdta (save_dta); return 0;} function name: RANDBWR function: random block write method: int RAMBWR (struct fcp * fcbptr, int RECCNT) : #Include #include #include #include int main (void) {char far * save_dta; char line [80]; char Line [80]; char Buffer [256] = "Randbwr Test!"; Struct FCB BLK; int result; / * get new file name from user * / printf ("Enter a file name to create" (no path - /:file.dat/ N "); gets (line); / * Parse the new file name to the dta * / parfnm (line, & blk, 1); Printf (" Drive #% D File:% S / N ", BLK.FCB_DRIVE, BLK .fcb_name ); / * Request DOS Services to create file * / if (BDoSPTR (0x16, & BLK, 0) == -1) {Perror ("Error Creating File"; EXIT (1);} / * Save Old DTA and SET New DTA * / Save_DTA = getdta (); setdta (buffer); / * Write new records * / BLK.FCB_Recsize = 256; BLK.FCB_RAndom = 0L; Result = RANDBWR (& BLK, 1); if (! Result) Printf "Write OK / N"); Else {Perror ("Disk Error"); EXIT (1);} / * Request DOS Services to Close THE FILE * / IF (BDoSPTR (0x10, & BLK, 0) == -1) {PERROR ("Error Closing File"); exit (1);} / * reset the Old DTA * / setdta (save_dta); Return 0;

} Function name: random function: random number generator usage: int Rando (int Num); program case: #include #include #include / * Prints a Random Number In the Range 0 to 99 * / int main (void) {randomize (); Printf ("Random Number In the 0-99 Range:% D / N", Random (100)); RANDOM (}): Randomize Function: Initializing Random Random Acer Usage: Void Randomize (Void); Project: #include #include #include int main (void) {INT i; Randomize ); Printf ("Ten Random Numbers from 0 to 99 / N / N"); for (i = 0; I <10; I ) Printf ("% D / N", RAND ()% 100); Return 0; } Function Name: Read function: Reading from the file: int inClude #include #include #include #include #include #include #include #include #include #include #include #include #include int main (void) {void * buf; int handle, Bytes; buf = malloc (10); / * Looks for A File In The Current Directory Named Test. $$$ and attempts to read 10 bytes from it. To UseXample You Should Create The File Test. $$$ * / if ((Handle = Open) , O_rdonly | o_binary, s_iwrite | s_iread) == - 1) {Printf ("Error Opening File / N" ); exit (1);} IF ((Bytes = Read (Handle, BUF, 10)) == -1) {Printf ("Read Failed./n"; Else {Printf (" Read:% D Bytes READ./N ", BYTES);} RETURN 0;} function name: Realloc function: Renotation of main departments: Void * Realloc (void * ptr, unsigned news: #include #include #include int main (void) {char * str; / * allocate memory for string * / str = malloc (10); / * Copy "Hello" Into String * / STRCPY (STR, "Hello"); Printf ("String IS% S / N Address IS% P / N", STR, STR); str = Realloc (STR, 20); Printf ("String IS% S / n new address is% p / n "

, STR, STR); / * free memory * / free (str);} function name: Rectangle Features: Draw a rectangular usage: Void Far Rectangle (int LEFT, INT TOP, INT Right, Int Bottom); program Example: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int left, top, right, bottom; / * 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 * /} left = getmaxx () / 2 - 50; top = getMaxy () / 2 - 50; right = getmaxx () / 2 50; bottom = getMaxy () / 2 50; / * Draw a Rectangle * / Rectangle (LEFT, TOP, RIGHT, BOTTOM); / * Clean Up * / getch (); Closegraph (); Return 0;} Function Name: RegisterBgidriver Features: Log in to Connected Graphics Driver Code Usage : Int RegisterBgidriver (Void (* driver)); program: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; / * register a driver what was added Into graphics .lib * / errorcode = registerbgidriver (EGAVGA_driver); / * report any registration errors * / if (errorcode <0) {printf ( "Graphics error:% s / n", grapherrormsg (errorcode)); printf ( "Press any key To Halt: "); getCH (); exit (1); / * Terminate with an error code * /} / * 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 * /} / * draw a line * / line (0, 0, getmaxx (), getmaxy ()); / * clean up * / getch (); closegraph (); return 0;} function Name: Remove Features: Delete a file usage: int Remove (Char * filename); program: #include int main (void) {char file [80]; / * prompt for file name to delete * / Printf ("File to Delete:"); gets (file); / * delete the file * / if (remote (file) == 0) Printf ("Removed% s. / n", file); elsePerror ("Remove "); RETURN 0;} function name: Rename function: Rename File Usage: int Rename (char * oldname, char * newname); program example: #include int main (void) {char Oldname [80 ], newname [80]; / * prompt for file to rename and new name * / printf ("File to Rename:"); Gets (OldName); Printf ("New Name:"); gets (newname); / * Rename the file * / if (Rename (OldName, NewName) == 0) Printf ("RenaMed% S TO% s. / N", OldName, NewName); ElsePerror ("Rename"); Return 0;} function name: RESTORECRTMODE Function: Restoring Screen Mode to Previous ImitGraph Settings: Voi D Far RestoreCRTMode (Void);: #include #include #include #include int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int x, y; / * 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 (erroorcode)); 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 any key to exit graphics:"); getch (); / * restore system to text mode * / restorecrtmode (); printf ( "We're now in text mode./n"" :printf ("press any key to return to graphics mode: "); getch (); / * return to graphics mode * / setgraphmode (getgraphmode ()); / * Output a message * / settextjustify (center_text, center_text); Outtextxy (x, y, "We're Back in graphics mode."); Outtextxy (x, y textheight ("w"), "Press Any Key to Halt: "); / * clean up * / getch (); closegraph (); return 0;} function name: REWIND function: Redirect file pointer to a stream: int Rewind (file * stream); program case: # INCLUDE #include int main (void) {file * fp; char * fname = "txxxxxx", * newname, first; newname = mktemp (fp = fopen (newname, " W "); FPRINTF (FP," AbcdefghijklmnopqrStuvwxyz "); ReWind (fp); FSCANF (FP,"% C ", & dimst); Printf (" THE FIRST CHARACTER IS:% C / N ", FIRST); fclose (FP ); RETURN 0;} function name: RMDIR function: Delete DOS file directory usage: int RMDir (Char * stream); program: #include #include #include #include #define dirname "TestDir. $$$" int main (void) {int stat; stat = mkdir (dirName); if (! stat) printf (" Directory createD / N "); else {printf (" Unable to create Directory / N); EXIT (1);} getCH (); system ("DIR / P"); getCh (); stat = rmdir (DIRNAME) ife ("/ ndirectory deleted / n"); else {perror ("/ NUNABLE TO Delete Directory / N); EXIT (1);} Return 0;} letter S start function function name: SBRK Function: Change data segment space location usage: char * sbrk (int inCr); program case: #include #include int main (void) {printf ("

Changing Allocation with sbrk () / n "); Printf (" Before Sbrk () Call:% Lu Bytes Free / N ", (Unsigned Long) Coreleft ()); SBRK (1000); Printf (" After Sbrk () Call :% lu bytes free / n ", (unsigned long) Coreleft ()); return 0;} function name: scanf function: Perform formatting input usage: int Scanf (char * format [, argument, ...]); CHINCLUDE #include int main (void) {char Label [20]; char name [20]; int entries = 0; int loop, age; double sales; struct entry_struct {Char Name [20]; int Age; float salary;} entry [20]; / * Input a label as a string of characters restrictingto 20 characters * / printf ("/ N / N / N / N / N / NPLEASE ENTER A Label for the chart:") Scanf ("% 20s", label); Fflush (stdin); / * flush the input stream in case of bad input * // * Input Number of entries as an integer * / printf ("How Many Entries Will there BE? (Less Than 20) "); scanf ("% D ", & entries); fflush (stdin); / * flush the input stream in case of bad input * /// * Input a name restricting input to only letters Upperor Lower Case * / for (loop = 0; loop

/ * Print Out the data what was input * / printf ("/ n / ntable% s / n", label); Printf ("Compiled BY% S AGE% D $% 15.2LF / N", Name, AGE, SALARY PRINTF ("------------------------------------------- - / ------- / n "); for (loop = 0; loop #include int main (void) {char * p; / * Looks for TLINK AND RETURns a Pointerto the Path * / P = SearchPath ("TLINK.exe"); Printf ("Search for TLINK.EXE:% S / N", P); / * Looks for Non-Existent File * / P = SearchPath ("NOTEXIST.FIL"); Printf ("Search for NotExist.fil:% S / N", P); Return 0;} function name: sector function: Draw and populate oval sectors Usage: Void Far Sector (int X, int y, int Stangle, int X, int in Endangle); #include #include #include #include int main (void) {/ * Request Auto Detection * / Int GDRIVE R = Detect, Gmode, ErrorCode; Int Midx, Midy, I; INT Stangle = 45, endangle = 135; int XRAD = 100, yrad = 50; / * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, " ); / * read results = graphresult (); if (erroorcode! = 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; / * loop through THE FILL PATTERNS * / for (i = EMPTY_FILL; i <

User_fill; i ) {/ * set the Fill Style * / setFillStyle (i, getmaxcolor ()); / * Draw the sector slice * / sector (MIDX, MIDY, STANGLE, Endangle, XRAD, YRAD); getCh ();} / * Clean up * / closegraph (); return 0;} function name: segread function: Read segment register value: Void segread (struct Sregs * segtbl); program: #include #include int main (void) {struct Sregs Segs; Segread (& Segs); Printf ("Current Segment Register Settings / N / N"); Printf ("CS:% x DS:% x / n", segs.cs, Segs.ds); Printf ("ES:% x SS:% x / n", segs.es, segs.ss); return 0;} function name: SetActivePage function: Setting graphic output activity page Usage: Void Far setActivePage INT PAGENUM); Question: #include #include #include int main (void) {/ * Select a driver and mode more supports * // * Multiple Pages. * / INT GDRIVER = EGA, GMODE = Egahi, ErrorCode; INT X, Y, HT; / * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "); / * Read Result OF INITIALIZATION * / ErrorCode = graphresult (); if (ErrorCode! = GROK) / * An error er c o c * / {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; ht = textheight ("w"); / * Select the off screen page for draking * / setactivepage (1); / * draw a line on page # 1 * / line (0, 0, getmaxx () , getmaxy ()); / * Output a message on page # 1 * / settextjustify (center_text, center_text); Outtextxy (x, y, "this is page # 1:"); Outtextxy (x, y HT, "Press Any Key to Halt: "); / * Select Drawing to Page # 0 * / setActivePage (0); / * Output A Message on Page # 0 * / OUTTEXTXY (X, Y," This IS Page # 0. ");

Outtextxy (x, y ht, "press any key to view page # 1:"); getch (); / * select page # 1 as the visible page * / setvisualpage (1); / * Clean up * / getch ); closegraph (); RETURN 0;} function name: setAllPallette function: Change all palette color usage by specifying: Void Far SetallPallette (Struct Palette, Far * Pallette); program: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; struct pastettype pal; int color, MaxColor, Ht; Int y = 10; Char MSG [80]; / * 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 (erroorcode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1 ); / * Terminate with an error code * /} maxColor = getMaxColor (); ht = 2 * textheight ("w"); / * grab a copy of the palette * / getpalette (& PAL); / * Display the default pastete Colors * / for (color = 1; color <= maxcolor; c) Olor ) {setColor (Color); Sprintf (MSG, "Color:% D", Color; OutTextxy (1, Y, MSG); Y = HT;} / * Wait for a key * / getch (); / * Black out the colors one by one * / for (color = 1; color <= maxcolor; color ) {setPalette (color, black); getch ();} / * restore the Palette Colors * / SetAllPalette (& Pal); / * Clean up * / getch (); closegraph (); return 0;} function name: setaspectratio function: Set graphical aspect ratio usage: Void Far setaspectratio (int XASP, INT YASP); program: #include #include #include #include int main (void) {/ * request auto detection * / int gDriver =

DETECT, gmode, errorcode; int xasp, yasp, 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 (erroorcode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1 ); / * terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; setColor (getMaxColor ()); / * get current aspect ratio settings * / getaspectratio (& XASP, & YASP) ; / * DRAW NORMAL CIRCLE * / CIRCLE (MIDX, MIDY, 100); getCh (); / * clar the screen * / clearden (); / * adjust the assect force (xaSP / 2, Yasp) ); Circle (MIDX, MIDY, 100); getCh (); / * adjust the aspect for a narrow circle * / clearden (); setaspectratio (XASP, YASP / 2); Circle (MIDX, MIDY, 100); / * Clean up * / getch (); closegraph (); return 0;} function name: setBkcolor function: Setting the current background color usage with palette: Void Far setbkcolor; program: #include #include #include #include int main (void) {/ * select a driver and mode this supports * // * multiple background colors. * / int gDriver = EGA, GMODE = Egahi, ErrorCode; int BKCOL, MaxColor, X, y; char msg [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = 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 AN Error Code * /} / * maximum color index supported * / maxColor = getMaxColor ();

/ * for centering text message * / setTextjustify (center_text, center_text); x = getmaxx () / 2; y = getMaxy () / 2; / * loop through the available colors * / for (bkcol = 0; bkcol <= maxcolor ; bkcol ) {/ * clear the screen * / clearden (); / * select a new background color * / setbkcolor (bkcol); / * Output a message * / if (bkcol == white) setColor (EGA_BLUE); Sprintf MSG, "Background Color:% D", BKCOL); OUTTEXTXY (X, Y, MSG); getCH ();} / * clean up * / closegraph (); return 0;} function name: setBlock function: Modify previously Assigned DOS Save Size Usage: Int setBlock (int SEG, INT Newsize); program: #include #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% D / N ", STAT); EXIT (1);} stat = setblock (segp, size * 2); if (stat == -1) Printf ("Expanded Memory Block At Segment:% x / n", segp); Elseprintf ("Failed: Maximu M Number of Paragraphs / Available IS% D / N ", STAT); FreeMem (segp); Return 0;} Function Name: SetBUF Function: Put the buffer with flow connections: void setbuf (file * steam, char * buf ); #Include / * bufsiz is defined in stdio.h * / char outbuf [buffs]; int main (void) {/ * attach a buffer to the standard Output stream * / setbuf (stdout , Outbuf; / * Put Some Characters INTO The Buffer * / PUTS ("This Is A Test Of Buffered Output./n/n/N": Puts ("th Output Will Go INTO OUTBUF / N "); PUTS (" AND Won't Appear Until The Buffer / N "); PUTS (" Fills Up or We Flush the Stream./N "); / * flush the output buffer * / fflush (stdout);

Return 0;} function name: SetCBRK function: Set Control-Break usage: int setccrk (int value); program: #include #include #include int main Void) {Int Break_flag; Printf ("Enter 0 to Turn Control Break Off / N); Printf (" Enter 1 To Turn Control Break ON / N); Break_Flag = Getch () - 0; SetCBRK (Break_Flag); if (Getcbrk ()) Printf ("cntrl-brk flag is on / n"); ElsePrintf ("cntrl-brk flag is off / n"); return 0;} function name: setColor function: Set the current line color usage: Void Far setColor (int color); program: #include #include #include #include int main (void) {/ * SELECT A Driver . and mode that supports * // * multiple drawing colors * / int gdriver = EGA, gmode = EGAHI, errorcode; int color, maxcolor, x, y; char msg [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result itis = 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 * /} / * maximum color index supported * / maxcolor = getmaxcolor (); / * for centering text messages * / settextjustify (CENTER_TEXT, CENTER_TEXT); x = getmaxx () / 2; y = getmaxy ( ) / 2; / * loop through the available colors * / for (color = 1; color <= maxcolor; color ) {/ * clear the screen * / clearden (); / * select a new background color * / setColor (Color ); / * Output a message * / sprintf (MSG, "Color:% D", Color; OutTextxy (x, y, msg); getCh ();} / * clean up * / closegraph (); return 0; } Function name: setdate function: Set DOS Date Usage: Void SetDate (Struct Date * DateBLK); Procedure: #include <

stdio.h> #include #include int main (void) {structure; struct date save_date; getdate; "Original Date: / N"); System ("Original Date: / N"); System "DATE"); reset.da_year = 2001; reset.da_day = 1; reset.da_mon = 1; setdate; "Date After Setting: / N"); System ("Date"); setDate (& Save_Date) PRINTF ("Back to Original Date: / N); System (" Date "); Return 0;} Function Name: SetDisk Features: Setup Current Disk Drive Usage: Int SetDisk (int DRIVE); program: #include #include int main (void) {int Save, Disk, Disks; / * save Original Drive * / save = getDisk (); / * print number of logic drives * / disks = setDisk (Save); Printf ("% D Logical Drives On The System / N / N", Disks); / * Print The Drive Letters Available * / Printf ("Available Drives: / N"); for (Disk = 0; Disk <26; disk; if (disk == getDisk ()) Printf ("% C: Drive is available / n", disk 'a');} setdisk (save); return 0 } Function name: setdta function: Set disk transfer area address usage: void setdta (Char Far * DTA); program: #include #include #include #include int main (v OID) ​​{char line [80], far * save_dta; char buffer [256] = "setdta test!"; struct fcb blk; int result; / * get new file name from user * / printf ("Enter a file name to Create: "); gets (line); / * Parse the new file name to the dta * / parfnm (line, & blk, 1); Printf ("% D% S / N ", BLK.FCB_DRIVE, BLK.FCB_NAME) ; / * Request dos Services to create file * / if (BDoSPTR (0x16, & BLK, 0) == -1) {Perror ("Error Creating File"); Exit (1);} / * Save Old DTA and Set New DTA * / save_dta = getdta (); setdta (buffer);

/ * Write new records * / blk.fcb_recsize = 256; BLK.FCB_RAndOM = 0L; Result = RandbWr (& BLK, 1); Printf ("Result =% D / N", Result); if (! result) Printf (" Write ok / n "); Else {PERROR (" Disk Error "); exit (1);} / * Request dos Services to close the file * / if (BDoSPTR (0x10, & BLK, 0) == -1) { Perror ("Error Closing File"); EXIT (1);} / * reset the Old DTA * / setdta (save_dta); Return 0;} function name: setFillPattern function: Select user-defined fill mode usage: Void Far setfillpattern CHAR FAR * Upattern, Int Color, the program: #include #include #include #include int main (void) {/ * Request Auto Detection * / int gDriver = detect, gmode, errorcode; int maxx, maxy; / * a user defined fill pattern * / char pattern [8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00}; / * 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 * /} maxx = getMaxx (); maxy = getMaxy (); setColor (getmaxcolor ()); / * SELECT A User Defined Fill Pattern * / setFillPattern (Pattern, getMaxColor ()); / * Fill the screen with the pattern * / bar (0, 0, maxx, maxy); / * Clean up * / getch (); closegraph (); Return 0;} function name: setFillStyle function: Set fill mode and color usage: Void Far setFillStyle (int pattern, int color); program: #include #include #include #include #include / * The names of the fill styles supported * / char * fname [] = {"

EMPTY_FILL "," SOLID_FILL "," LINE_FILL "," LTSLASH_FILL "," SLASH_FILL "," BKSLASH_FILL "," LTBKSLASH_FILL "," HATCH_FILL "," XHATCH_FILL "," INTERLEAVE_FILL "," WIDE_DOT_FILL "," CLOSE_DOT_FILL "," USER_FILL " }; int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int style, midx, midy; char stylestr [40]; / * 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 * /} midx = getmaxx () / 2; midy = getmaxy () / 2; For (Style = Empty_Fill; Style #include #include int main (void) {struct ftime filet; file * fp; if ((fp = fopen) "TEST. $$$", "w")) == NULL) {Perror ("Error:"); EXIT (1);} fprintf (fp, "testing ... / n"); / * load ftime Structure with new time and date * / filet.ft_tsec = 1; filet.ft_min = 1; filet.ft_Hour = 1; filet.ft_day = 1; filet.ft_month = 1;

Filet.ft_year = 21; / * Show Current Directory for Time and Date * / System ("Dir Test. $$$"); / * Change the time and date stamp * / setftime (FILENO (FP), & Filet); / * Close and remove the temporary file * / fclose (fp); System ("Dir Test. $$$"); unlink ("Test. $$$"); returnof;} function name: setgraphbufsize function: change internal graphics Size usage: unsigned far setgraphbufsize (unsigned bufsize); program example: #include #include #include #include #define buffs 1000 / * INTERNAL graphics buffer size * / int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int X, y, oldsize; char msg [80]; / * set the size of the intence graphics buffer * // * before making a call to initgraph * / oldsize = setgraphbufsize (BUFSIZE);. / * 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 * /} x = getmaxx () / 2; y = getmaxy () / 2; / * Output Some Messages * / Sprintf (MSG, "Graphics Buffer size:% d ", buffs); setTextjustify (center_text, center_text); Outtextxy (x, y, msg); sprintf (MSG," Old Graphics Buffer Size:% D ", OldSize; Outtextxy (x, y textheight ("W"), MSG); / * clean up * / getch (); closegraph (); return 0;} function name: setgraphmode function: Set the system into graphics mode and clear screen usage: Void Far setgraphmode (int MODE) );: #Include #include #include #include int main (void) {/ * request auto detection * / int gDriver =

DETECT, gmode, errorcode; int x, y; / * 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 * /} x = getmaxx () / 2; y = getMaxy () / 2; / * Output a message * / settextjustify (center_text, center_text); Outtextxy (x, y, "press any key to exit Graphics: "); getch (); / * restore system to text mode * / restoreCRTMode (); printf (" We're now in text mode./n" );printf ("press any key to return to graphics mode: "); getch (); / * return to graphics mode * / setgraphmode (getgraphmode ()); / * output a message * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (x, y," We're back in graphics mode Outtextxy (X, Y TextHeight ("W"), "Press any key to halt:"); / * clean up * / getch (); closegraph (); return 0;} function name: setjmp function : Non-local transfer usage: int setJMP (jmp_buf env); program case: #i NClude #include Void subs void subs (void); JMP_buf jumper; int main (void) {int value; value = setjmp (jumper); if (value! = 0) {Printf ("longjmp with value% d / n", value); exit (value); "About to call subs ... / n"); subroutine (); return 0;} void subs Void) {longjmp (Jumper, 1);} function name: setLinesTyle Features: Set Current Paint Width and Type Usage: Void Far SetLinesTyle (int Linestype, unsigned Upattern); program: #include #include < Stdlib.h> #include #include #include

/ * the names of the line styles supported * / char * LNAME [] = {"Solid_Line", "Dotted_Line", "Center_Line", "Dashed_Line", "Userbit_Line"}; int main (void) {/ * Request Auto Detection * / int gdriver = DETECT, gmode, errorcode; int style, midx, midy, userpat; char stylestr [40]; / * 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; / * a user defined line pattern * // * Binary: "0000000000000001" * / userpat = 1; for (Style = SOLID_LINE; style <= userbit_line; style ) {/ * Select the line style * / setlinestyle (style, userpat, 1); / * Convert Style Into a string * / STRCPY (StyleStr, LName [style]); / * draw a line * / line (0, 0, miDX-10, midy); / * draw a rectangle * / Rectangle (0, 0, getmaxx (), getMax ))); / * Output A Message * / Outtextxy (MIDX, MIDY, STYLESTR); / * Wait for a key * / getch (); clearDevice ();} / * clean up * / closegraph (); return 0;} function name: setMEM function : To save to storage area usage: void setmem (void * addr, int LEN, char value); program case: #include #include #include int main (void ) {char * DEST; DEST = Calloc (21, sizeof (char)); SetMem (DEST, 20, 'C'); Printf ("% S / N", DEST); RETURN 0;} function name: setMode function : Setting Open File Method: Int setMode (int Handle, unsigned mode); program: #include #include #include int main (void) {int result; Result =

SetMode (Fileno (stdprn), o_text); if (Result == -1) PERROR ("Mode Not Available / N"); ElsePrintf ("Mode SuccessFully Switch / N"); return 0;} function name: setPalette function: Change the color usage of the palette: Void Far setpalette (int index, int actural_color); program: #include #include #include #include int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int color, maxcolor, ht; int y = 10; char msg [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result itis = graphresult (); if (errorcode! = grok) / * an error ire {Printf ("graphics error:% s / n", GrapherrorMSG ("Press Any Key to Halt:"); GetCh (); EXIT (1); / * Terminate with an error code * /} maxcolor = getMaxColor (); ht = 2 * textheight (" W "); / * Display the default colors * / for (color = 1; color <= maxcolor; color ) {setColor (color); Sprintf (MSG," Color:% D ", Color; Outtextxy (1, Y , MSG); Y = HT;} / * Wait for a key * / getch (); / * black Out the colors one by one * / for (color = 1; color <= maxColor; color ) {setPalette (color, black); getch ();} / * clean up * / closegraph (); return 0;} function name : SETRGBPALETTE Function: Defines the color usage of IBM8514 graphics card: Void Far SetRGBPalette (int color, int red, int green, int blue); program case: #include #include #include #include int main (void) {/ * select a driver and mode supports the us * // * of the setrgbpalette function. * / int gDriver = VGA, GMODE = VGAHI, ERRORCODE; STRUCT PaletType Pal; INT I, HT, Y, XMAX;

/ * 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", GraphherrorMSG (ERRORCODE)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} / * grab A Copy of the Palette * / GetPalette (& PAL); / * CREATE GRAY SCALE * / for (i = 0; i #include #include #include / * Function Prototype * / Void XAT (INT X, INT Y); / * Horizontal Text Justification Settings * / Char * Hjust [] = {"LEFT_TEXT", "Center_Text", "Right_Text"}; / * Vertic al text justification settings * / char * vjust [] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT"}; int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx , Midy, HJ, VJ; CHAR MSG [80]; / * 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; / * loop through text justification/ / for (hj = left_text; hj <= right_text; hj ) for (VJ = Left_text; vj <= right_text; vj ) {clearyvice (); / * set the text justification * / settextjustify (hj, vj); / * create a message string * / sprintf (msg, "% s% s", hjust [hj], vjust [vj]); / * Create Cross Hairs on the screen * / xat (midx, midy); / * Output the message * / Outtextxy (MIDX, MIDY, MSG); getCh ();} / * Clean up * / closegraph (); return 0;} / * Draw AN "X" AT (x, y) * / void xat (int x, int y) {line (x-4, y, x 4, y LINE (x, y-4, x, y 4);} function name: setTextStyle function: Set the current text attribute usage for graphics output: Void Far SetTextStyle (int Font, int Direction, char size); : #include #include #include #include / * The names of the text styles supported * / char * fname [] = {"Default Font "," Triplex Font "," SMALL FONT "," Gothic font "}; int main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int Style , Midx, midy; int size = 1; / * 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; settextjustify (CENTER_TEXT, CENTER_TEXT); / * loop through the available text styles * / for (style = DEFAULT_FONT; style <= GOTHIC_FONT ; Style

) {CLEARDEVICE (); if (style == triplex_font) size = 4; / * select the text style * / settextStyle (style, horiz_dir, size); / * Output a message * / Outtextxy (MIDX, Midy, FName [style ]); getCH ();} / * clean up * / closegraph (); return 0;} function name: settime function: Setting system time usage: void setTime (Struct Time * TimeP); program case: #include #include int main (void) {struct time t; gettime (& t); Printf ("THE CURRENT Minute IS:% D / N", T.TI_MIN); Printf ("THE CURRENT HOUR IS) :% D / N ", T.Ti_Hour); Printf (" THE CURRENT HUNDREDTH OF A Second IS:% D / N ", T.TI_HUND); Printf (" THE Current Second IS:% D / N ", T. Ti_sec); / * add one to the minutes structure * / t.ti_min ; settime (& T); Return 0;} function name: setusercharsize function: To change character width and high usage for vector font: Void Far setusercharsize INT MULTX, INT DIRX, INT MULTY, INT DIRY; program: #include #include #include #include int main (void) { / * Request Autodetection * / INT GDRIVER = Detect, Gmode, ErrorCode; / * Initialize Graphics and Local Variables * / Initgraph (&) GDRIVER, & GMODE, "" "/ * read results = graphresult (); if (erroorcode! = 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 * /} / * select a text style * / settextStyle (Triplex_Font, Horiz_Dir, 4); / * move to the text starting position * / moveto (0, getmaxy () / 2); / * Output Some Normal text * / OutText ("norm"); / * make the text 1/3 The Normal Width * / setusercharsize (1, 3, 1, 1); OutText ("Short");

/ * Make The Text 3 Times Normal Width * / Setusercharsize (3, 1, 1, 1); Outtext ("Wide"); / * Clean Up * / GetCh (); Closegraph (); Return 0;} Function Name: Setvbuf function: Put the buffer with streams: int setvbuf (file * stream, char * buf, int type, unsigned size); program: #include int main (void) {file * input, * Output; char bufr [512]; input = fopen ("file.in", "R B"); Output = FOPEN ("File.out", "W"); / * SET UP INPUT STREAM for Minimal Disk Access USING OUR OWN Character Buffer * / IF (SetVBUF (Input, Bufr, _iofbf, 512)! = 0) Printf ("Failed to Set Up Buffer For Input File / N"); ElsePrintf ("Buffer Set Up for Input File / N "); / * set up output stream for line buffering sale space, Will Be Obtained THROUGH AN Indirect Call Tomalloc * / IF (SetVBUF (Output, Null, _iolbf, 132)! = 0) Printf (" Failed to set up buffer for Output file / n "); ElsePrintf (" Buffer Set Up for Output File / N "); / * Perform File I / O Here * / / * Close Files * / Fclose (Input); Fclose (Output); Return 0; } Function name: setVect function: Set interrupt vector entry usage: void setVect (int INTR_NUM, VOID INTERRUPT (* ISR) )); Example of program:. / *** NOTE: This is an interrupt service routine You can NOTcompile this program with Test Stack Overflow turnedon and get an executable file which will operatecorrectly * / # include #include <. DOS.H> #include #define INTR 0x1C / * The clock tick interface interrupt * / void interrupt (* OldHandler) (void); int count = 0; void interrupt handler (void) {/ * increable the global counter * / count ; / * 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 unsteil 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: setverify function: Set the verification status usage: void setver (int value); program case: #include #include #include int main (void) {int verify_flag PRINTF ("Enter 0 TO SET VERIFY FLAG OFF / N"); Printf ("Enter 1 TO Set Verify Flag ON / N); Verify_Flag = Getch () - 0; setverify; if (Getverify ()) Printf ("DOS VERIFY FLAG IS ON / N); ElsePrintf (" DOS Verify Flag IS Off / N "); Return 0;} Function Name: SetViewPort Function: Set the current viewport for graphic output: Void Far setViewPort (int LEFT, INT TOP, INT Right, Int Bottom, Int Clipflag / * activates clipping in viewport * / int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * Read Result of Initialization * / ErrorCode = Grap HRESULT (); 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 * /} setColor (getMaxColor ()); / * 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 text * / Outtextxy (0, 0, "* <- (0, 0) in smaller viewport"); / * Clean up * / getch (); closegraph (); return 0;

} Function Name: SetvisualPage Function: Setting visible graphic page number: Void Far setvisualpage (int Pagenum); program case: #include #include #include #include int main (void) {/ * select a driver and mode this supports * // * Multiple pages. * / int gahi = EGA, GMODE = Egahi, ErrorCode; INT X, Y, HT; / * 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 * /} x = getmaxx () / 2; y = getmaxy () / 2; ht = textheight ("w"); / * select the off screen page for Drawing * / setActivePage (1); / * Draw a line on page # 1 * / line (0, 0, GetMaxx (), getMaxy ()); / * Output a message on page # 1 * / settextjustify (center_text, center_text); Outtextxy (x, y, "this is page # 1:"); Outtextxy (x, y HT "Press any key to halt:"); / * Select Drawing to Page # 0 * / setActivepa GE (0); / * Output A Message on Page # 0 * / OUTTEXTXY (X, Y, "This IS Page # 0); Outtextxy (x, y ht," Press Any Key to View Page # 1: "); getch (); / * Select Page # 1 as the visible page * / setvisualpage (1); / * clean up * / getch (); closegraph (); returnography;} function name: setWriteMode function: Setting graphics Method of Output Mode Usage: Void Far SetWritemode (int mode); program example: #include #include #include #include int main () {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; INT XMAX, YMAX; / * Initialize Graphics and 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 * /} xmax = getmaxx (); ymax = getMaxy (); / * select xor drawing mode * / setwritemode XOR_PUT); / * DRAW a line * / line (0, 0, xmax, ymax); getch (); / * Erase the line by drawing over it * / line (0, 0, xmax, ymax); getch () / * Select overwrite drawing mode * / setwritemode; / * draw a line * / line (0, 0, xmax, ymax); / * clean up * / getch (); closegraph (); return 0;} Function Name: Signal Features: Setting a Signal Signal Method: Int Signal (int SiG, SIGFUN FNAME); program: / * This Example Installs a signal handler routine for sigfpe, catches an adjustmentto AX register, and returns. This example program MAY causeyour computer to crash, and will produce runtime errorsdepending on which memory model is used. * / # pragma inline # include #include voi D catcher (int SIG, INT TYPE, INT * REGLIST) {Printf ("caught it! / n"); * (Reglist 8) = 3; / * make return = 3 * /} int main (void) { Signal (SIGFPE, CATCHER); ASM MOV AX, 07FFFH / * AX = 32767 * / AX = 32767 * / asm incov / * cause overflow * / / / * the handler set ax i 3 on return. if That Hadn 'thappened, there would have been another exceptionwhen the next' into 'was executed after the' dec'instruction * / asm dec ax / * no overflow now * / asm into / * does not activate * / return 0;.} functions Name: SIN Function: Sinusoidal Function Usage: Double Sin (Double X); Procedure: #include #include int main (void) {Double Result, x = 0.5; Result = sin x); Printf (""

THE SIN () OF% LF IS% LF / N ", X, Result); Return 0;} function name: SINH function: Double Strove Function Usage: Double Sinh (Double X); Project: #include #include int main (void) {double result, x = 0.5; result = sinh (x); Printf ("The HyperBolic sin () OF% LF IS% LF / N", X, Result ); RETURN 0;} function name: SLEEP function: Perform a period of time: unsigned sleep (unsigned seconds); program: #include #include int main (void) {INT i; for (i = 1; i <5; i ) {printf ("Sleeping for% D Seconds / N", I); SLEEP (i);} return 0;} function name: SOPEN function: Open a share file Usage: int sithname, int access, int shflag, int permiss; program: #include #include #include #include #include #include int main (void) {int Handle; int status; handle = Sopen ("c: //autoexec.bat", o_rdonly, sh_denyno, s_iread); if (! Handle) {Printf ("Sopen Failed / N"); exit (1);} status = access ("c: //autoexec.bat", 6); if (status == 0) Printf ("Read / Write access allowed / N "); ElsePrintf (" Read / Write Access Not Allowed / N); Close (Handle); Return 0;} Function Name: SOUND function: Open in the specified frequency PC speaker usage: void Sound (unsigned frequency); program: / * Emits a 7-Hz Tone for 10 seconds.your pc May Not Be Able To Emit A 7-Hz Tone. * / # Include int Main (void) {Sound (7); DELAY (1000); Nosound (); return 0;} function name: spawnl function: Create and run subsurgery: int Spawnl (int mode, char * pathname, char * arg0, Arg1, ... argn, null; program: #include #include #include int main (void) {int result; clrs CR (); result = spawnl (P_wait, "tcc.exe", null; if (result == -1) {PERROR ("Error from spawnl"); exit (1);} return 0;

} Function Name: Spawnle Features: Create and run subsurgers: int Spawnle (int MODE, CHAR * PATHNAME, CHAR * ARG0, Arg1, ..., argn, null); #include #include #include int main (void) {int result; clrsCr (); result = spawnle (p_wait, "tcc.exe", null, null) ; f ("error from spawnle"); exit (1);} return 0;} function name: sprintf function: send formatted output to string Usage: int Sprintf (char * String, char * farmat [, argument, ...]);: #include #include int main (void) {char buffer [80]; sprintf (buffer, "ann Approximation Of IS% F / N ", M_PI); PUTS (BUFFER); Return 0;} function name: SQRT function: calculate square root method: double sqrt (double x); program case: #include # INCLUDE int main (void) {double x = 4.0, result; result = sqrt (x); Printf ("The Square Root OF% LF IS% LF / N", X, Result; Return 0; } Function name: SRAND function: initialization random number generator usage: Void Srand (unsigned seed); example: #include #include #include int main (void) {INT I; TIME_T T; SRAND (& T)); Printf ("Ten Random Numbers from 0 to 99 / N / N"); for i = 0; I <10; I ) Printf ("% D / N", RAND ()% 100); RETURN 0;} function name: SSCANF function: Perform formatting input from strings: int SSCANF Char * string, char * format [, argument, ...]); program example: #include #include int main (void) {char Label [20]; char name [20 INT entries = 0; int Loop, age; double salary; struct entry_struct {char name [20]; int Age; float salary;} entry [20]; / * Input a label as a string of characters restrictingto 20 characters * / Printf ("/ N / N / NPLEASE ENTER A Label for THE CHART:"); Scanf ("% 20s", Label); FFlush (stdin);

/ * Flush the Input Stream in case of bad input * /// * INPUT NUMBER OF ENTRIES AS ANTEGER * / PRINTF ("How Many Entries Will Tw (" Less Than 20) "); Scanf ("% D ", & Entries ); fflush (stdin); / * flush the input stream in case of bad input * // * Input a name restricting input to online * / for (loop = 0; loop #include #include #define filename "Test. $$$" int main (void) {structure stattbuf;

File * stream; / * open a file for update * / if (stream = fopen (filename, "w ")) == null) {fprintf (stderr, "cannot open output file./n" ";return(1 } / * get information about the file * / stat (filename, & statbuf); fclose (stream); / * Display the information returned * / if (statbuf.st_mode & s_ifi) Printf ("Handle ReferS to a device./ N "); if (statbuf.st_mode & s_ifreg) Printf (" Handle Refers to an ORDINARY FILE./N ":" "User Has Read Permission on File./N"); IF (statbuf.st_mode & s_iwrite) Printf ("User Has Write Permission on File./N); Printf (" Drive Letter Of File:% C / N ", 'A' Statbuf.st_Dev); Printf (" SIZE Of file in bytes:% ld / n ", statbuf.st_size); Printf (" Time File Last Opened:% S / N ", CTIME (& statbuf.st_ctime)); Return 0;} function name: _status87 function: Floating Point status usage: unsigned int _Status87 (void); program example: #include #include int main (void) {float x; double y = 1.5e-100; printf ("status 87 Before error:% x / n ", _status87 ()); x = y; / * <- force an error to ioccur * / y = x; printf (" ST ATUS 87 After Error:% X / N ", _STATUS87 ()); Return 0;} function name: STIME function: Setting time usage: int 2; program: #include #include #include int main (void) {TIME_T T; StructTM * Area; T = Time (null); Area = localtime (& T); Printf ("Number of Seconds Since 1/1 / 1970 IS:% LD / N ", T); Printf (" Local Time IS:% S ", Asctime (Area)); T ; Area = LOCALTIME (& T); Printf (" Add A Second:% S ", Asctime (Area)); T = 60; Area = LocalTime (& T); Printf ("Add A Minute:% S", Asctime (Area)); T = 3600;

Area = localtime (& T); Printf ("Add AN Hour:% S", Asctime (Area)); T = 86400L; Area = LOCALTIME (& T); Printf ("Add a day:% s", asctime (Area )); t = 2592000L; Area = localtime (& T); Printf ("Add A Month:% S", Asctime (AREA)); T = 31536000L; Area = LOCALTIME (& T); Printf ("Add a year :% s ", asctime (area); return 0;} function name: stpcpy function: copy a string to another: char * stpcpy (char * source); program case: #include #include int main (void) {char string [10]; char * str1 = "abcdefghi"; stpcpy (string, str1); Printf ("% s / n", string); Return 0;} function name: STRCAT function: string splicing function usage: char * STRCAT (CHAR * DESTIN, CHAR * SOURCE); program example: #include #include int main (void) {Char Destination [25]; char * blank = "", * c = "c ", * borland = "borland"; strcpy (destination, blank); strcat (destination, c); printf ("% s / n", destination; RETURN 0;} function name: strchr function: Find the first match of a given character in a string / usage: char * str, char C) : #Include #include int main (void) {char string [15]; char * PTR, C = ' R '; strcpy (String, "this is a string"); ptr = strchr (string, c); if (ptr) printf ("THE CHARACTER% C IS At Position:% D / N", C, PTR-String Elseprintf ("THE Character Was Not Found / N); Return 0;} Function Name: STRCMP Function: String Comparison Usage: Int strcmp (Char * STR1, CHAR * STR2); program example: #include #include int main (void) {char * buf1 = "aaa", * buf2 = "bbb", * buf3 = "ccc"; int PTR; PTR = STRCMP (BUF2, BUF1); IF PTR> 0) Printf ("Buffer 2 IS Greater Than Buffer 1 / N");

ElsePrintf ("Buffer 2 IS Less Than Buffer 1 / N); PTR = STRCMP (BUF2, BUF3); IF (PTR> 0) Printf (" Buffer 2 IS Greater Than Buffer 3 / N "); Elseprintf (" Buffer 2 Is Less Than Buffer 3 / N "); RETURN 0;} function name: strncmpi function: Compare a part of a string with another string, regardless of case: int strncmpi (char * str1, char * str2, unsigned maxlen ); #Include #include int main (void) {char * buf1 = "bbb", * buf2 = "bbb"; int PTR; PTR = Strcmpi (buf2, buf1 ); IF (PTR> 0) Printf ("Buffer 2 IS Greater Than Buffer 1 / N); if (PTR <0) Printf (" Buffer 2 IS LESS THAN Buffer 1 / N); if (Ptr == 0 ) PRINTF ("Buffer 2 Equals Buffer 1 / N); Return 0;} Function Name: STRCPY Function: String Authentic: Char * Strcpy (Char * STR1, CHAR * STR2); Question: #include #include int main (void) {char string [10]; char * str1 = "abcdefghi"; strcpy (string, str1); Printf ("% s / n", string); return 0; } Function Name: STRCSPN Function: Find a paragraph usage of the first given character set content in the string: int Strcspn (Char * STR1, CHAR * STR2); program example: #include #include #include int main (void) {char * String1 = "1234567890"; char * string2 = "7 47DC8 "; intleth; length = strcspn (string1, string2); Printf (" Character WHERE STRING2 IS AT / POSITION% D / N ", Length); Return 0;} Function Name: STRDUP function: copy the string to new construction Location Application: Char * STRDUP (Char * STR); CHAR * STRDIO.H> #include #include int main (void) {char * dup_str, * string = "abcde"; dup_str = strdup (strint); Printf ("% s / n", dup_str); free (DUP_STR); RETURN 0;} function name: stricmp function: compare two string uses in case sensitive mode : int Stricsp (Char * str1, char * STR2);: #include #include

INT main (void) {char * buf1 = "bbb", * buf2 = "bbb"; int PTR; PTR = Stricmp (BUF2, BUF1); if (PTR> 0) Printf ("Buffer 2 Is Greater Than Buffer 1 / n "); if (ptr <0) Printf (" Buffer 2 IS Less Than Buffer 1 / N "); if (PTR == 0) Printf (" Buffer 2 Equals Buffer 1 / N "); return 0;} function Name: StroRROR function: Returns pointer usage to the error message string: char * strerror (int errnum); program: #include #include int main (void) {char * buffer; Buffer = strerror (errno); Printf ("Error:% S / N", Buffer; Return 0;} function name: strcmpi function: Put a string with another comparison, regardless of case: int standardmpi (char * str1 CHAR * STR2);: #include #include int main (void) {char * buf1 = "bbb", * buf2 = "bbb"; int PTR; PTR = Strcmpi (BUF2, BUF1); IF (PTR> 0) Printf ("Buffer 2 IS Greater Than Buffer 1 / N"); IF (PTR <0) Printf ("Buffer 2 IS Less Than Buffer 1 / N); IF ( PTR == 0) Printf ("Buffer 2 Equals Buffer 1 / N"); Return 0;} Function Name: Strlen Features: Calculation Skewers: Unsigned Strlen (Char * STR); program example: #include #include int main (void) {char * string = "borland international"; printf ("% d / n", Strlen (String); RETURN 0;} function name: strlwr function: Convert strings to lowercase form: char * strlwr (char * STR); program: #include #include INT main (void) {char * String = "borland International"; Printf ("String Prior to Strlwr: S / N", String); strlwr (String); Printf ("String After Strlwr: S / N", String); RETURN 0;} function name: strncat function: String splicing usage: char * strncat (char * destin, char * source, int maxlen); program: #include #include INT main (void) {char Destination [25]; char * source = "states";

STRCPY (DESTINATION, "United"); StrNcat (Destination, Source, 7); Printf ("% s / n", destination); return 0;} function name: STRNCMP function: String Compare: int STRNCMP (Char * STR1 , Char * STR2, INT MAXLEN; program example: #include #include int main (void) {char * buf1 = "aaabbb", * buf2 = "bbbccc", * buf3 = "CCC"; int PTR; PTR = Strncmp (BUF2, BUF1, 3); if (PTR> 0) Printf ("Buffer 2 IS Greater Than Buffer 1 / N); Elseprintf (" Buffer 2 IS Less Than Buffer 1 / n "); PTR = Strncmp (BUF2, BUF3, 3); if (PTR> 0) Printf (" Buffer 2 IS Greater Than Buffer 3 / N "); ElsePrintf (" Buffer 2 IS Less Than Buffer 3 / N ") Return (0);} function name: Strncmpi function: Compares part of the string with another string, regardless of case: int Strncmpi (Char * str1, char * str2); program: #include < String.h> #include int main (void) {char * buf1 = "bbbccc", * buf2 = "bbbccc"; int PTR; PTR = Strncmpi (BUF2, BUF1, 3); if (PTR> 0) Printf ("Buffer 2 IS Greater Than Buffer 1 / N); IF (PTR <0) Printf (" Buffer 2 IS LESS THAN Buffer 1 / N); if (PTR == 0) Printf ("Buffer 2 Equals buffer 1 / n "); Return 0;} function name: STRNCPY function: String copy usage: char * STRN CPY (CHAR * DESTIN, CHAR * SOURCE, INT MAXLEN); Questions: #include #include int main (void) {char string [10]; char * str1 = "abcdefghi" StrinTf (String, STR1, 3); String [3] = '/ 0'; Printf ("% S / N", String); return 0;} function name: strnicmp function: two comparison Series: int Strnicmp (Char * STR1, Char * STR2, UNSIGNED MAXLEN); Question: #include #include int main (void) {char * buf1 = "bbbccc", * BUF2 = "bbbccc"; int PTR; PTR = Strnicmp (BUF2, BUF1, 3); if (PTR> 0) Printf (""

Buffer 2 IS Greater Than Buffer 1 / N "); IF (PTR <0) Printf (" Buffer 2 IS Less Than Buffer 1 / N); if (PTR == 0) Printf ("Buffer 2 Equals Buffer 1 / N "); RETURN 0;} function name: strnset function: set all characters in a string to specify character usage: char * strnset (char * str, char ch, unsigned n); program case: #include #include int main (void) {char * string = "abcdefghijklmnopqrstuvwxyz"; char letter = 'x'; Printf ("String Before Strnset:% S / N", String); strnset (String, Letter, 13); Printf ("String After Strnset:% S / N", String); Return 0;} Function Name: StrPBRK Function: Finding Characters Used in String Character Conses: Char * Strpbrk (Char * STR1 , Char * STR2);: #include #include int main (void) {char * string1 = "abcdefghijklmnopqrstuvwxyz"; char * string2 = "onm"; char * ptr; PTR = StrPbrk (strPBRING1, String2); if (ptr) Printf ("StrPBRK Found First Character:% C / N", * PTR); ElsePrintf ("StrPBRK Didn't Find Character In Set / N"); Return 0;} Function Name: STRRCHR Function: Find the last occurrence of the specified character in the string: char * STRCHR (Char * Str, CHAR C); program: #include #include int main Void) {char string [15]; cha R * ptr, c = 'r'; strcpy (string, "this is a string"); ptr = strrchr (string, c); if (ptr) printf ("THE Character% C Is At position:% D / N) "C, PTR-STRING; ElsePrintf (" THE Character Was Not Found / N); Return 0;} Function Name: Strrev Function: Skemper Down: Char * Strrev (Char * Str); Procedure: #include #include int main (void) {char * forward = "string"; Printf ("Before StrRev ():% S / N", Forward); strRrev (Forward); Printf "After strrev ():% s / n", forward); Return 0;} function name: strSet function: set all characters in a string to specify character usage: char * str, char C) ;

Sample example: #include #include int main (void) {char string [10] = "123456789"; char Symbol = 'c'; printf ("Before strs ():% s / n ", string); strset (String, Symbol); Printf (" After StRSET ():% S / N ", String); Return 0;} Function Name: STRSPN Function: Find the specified character set in the string The first use of the set: int StRSPN (Char * STR1, CHAR * STR2);: #include #include #include int main (void) { Char * string1 = "1234567890"; char * string2 = "123DC8"; intlene; length = strspn (string1, string2); Printf ("Character WHERE STRINGS AT POSITION /% D / N", Length); Return 0 (}) Function name: Strstr function: Find the first appearance usage of the specified string in the string: char * str1, char * STR2); program example: #include #include int main (void) {char * str1 = "borland international", * str2 = "nation", * ptr; ptr = strs (str1, str2); Printf ("the substring is:% s / n", PTR RETURN 0;} function name: Strtod function: convert a string to Double type value usage: Double Strtod (Char * STR, Char ** Endptr); program: #include #include int main (void) {char INPUT [80], * Endptr; Double Value; Printf ("Enter A Floating P Oint Number: "); Gets (Input); Value = STRTOD (Input, & Endptr); Printf (" THE STRING IS% S the Number IS% LF / N ", Input, Value; Return 0;} function name: Strtok Function: Find the word usage separated by the division split by the division in the second string: char * str1, char * STR2); example: #include #include int main (void) {char input [16] = "abc, d"; char * p; / * starting places a null terminatorin front of the token, if found * / p = strtok (input, ","); IF (p) Printf ("% s / n", p);

/ * A Second Call to StrtoK ​​Using A NULLAS The First Parameter Returns a Pointerto The Character Following The Token * / P = Strtok (Null, ","); if (p) Printf ("% s / n", p); Return 0;} function name: Strtol function: Convert strings into long integer usage: long start (char * str, char ** endptr, int base); program: #include #include int main (void) {char * string = "87654321", * endptr; long lnumber; / * string, string to long integer * / lnumber = string to long integer * / lnumber = string to long integer * / lnumber = string to long integer * / lnumber = string to long integer * / lnumber = string to long integer * / lnumber = string = string =% ld / n ", string, lnumber); Return 0;} function name: STRUPR function: convert lowercase letters in the string to uppercase letters usage: char * strupr (char * STR); program: #include #include int main (void) {char * string = "abcdefghijklmnopqrstuvwxyz", * PTR; / * Converts string to up UPER case Case Characters * / PTR = STRUPR (String); Printf ("% s / N ", PTR); RETURN 0;} function name: SWAB function: exchange byte usage: void swab (char * from, char * to, int nbytes); program case: #include #include #include char Source [15] = "RFNA KoblRNA D"; Char Target [15]; int Main (void) {swab (Source, Target, Strlen (Source)); Pr INTF ("This Is Target:% S / N", TARGET; RETURN 0;} Function Name: System Features: Int System (Char * Command); Project: #include #include int main (void) {printf ("About to spawn command.com and run a dos / command / n"); system ("dir"); return 0;} letter T start function function name : TAN Function: Positive Split Function: Double Tan (Double X); Procedure: #include #include int main (void) {Double Result, X; X = 0.5; Result = Tan (x); Printf ("THE TAN OF% LF IS% LF / N", X, Result); RETURN 0;} function name: Tanh function: Double-tone orthogonal function method: double tanh (double x); program case: #include #include <

Math.h> int main (void) {Double Result, X; X = 0.5; Result = Tanh (x); Printf ("The HyperBolic Tangent Of% LF IS% LF / N", X, Result; Return 0; } Function name: TELL function: Current location usage of file pointer: long tell (int Handle); program: #include #include #include #include int main (void) {INT HANDLE; char msg [] = "Hello World"; if ((Handle = Open ("Test. $$$", o_creat | o_text | o_append) == -1) { PERROR ("Error:"); Return 1;} Write (Handle, MSG, Strlen (MSG)); Printf ("The File Pointer IS AT BYTE% LD / N", Tell (Handle); Close (Handle); Return 0;} function name: TextatTR function: set text attribute usage: void texttr (int attribute); program case: #include int main (void) {Int i; clrs CR (); for (i = 0 i <9; i ) {textttr (i ((((i 1) << 4)); CPRINTF ("this is a test / r / n");} return 0;} function name: Textbackground function: Select New text background color usage: void textbackground (int color); program case: #include int main (void) {Int i, j; clrs CR (); for (i = 0; i <9; i ) ) {for (j = 0; j <80; j ) cprintf ("c"); cprintf ("/ r / n"); TextColor (i 1); TextbackGround (i);} return 0;} function name : TextColor function: Select new character color usage in text mode : Void textColor (int color); program case: #include int main (void) {INT i; for (i = 0; i <15; i ) {TextColor (i); CPRINTF ("Foreground Color / r / n ");} RETURN 0;} function name: TextHeight function: Return to a string height of pixels: int FAR TEXTHEIGHT (Char Far * TextString); program: #include # Include #include #include int main (void) {/ * request auto detection * / int gdriver = detect, gmode, errorcode; int y = 0; int 1; Char MSG [80]; / * Initialize Graphics and Local Variables * / Initgraph (& GDriver, &)

Gmode, ""); / * read results = graphresult (); if (erroorcode! = 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 * /} / * DRAW Some text on the screen * / for (i = 1; i <11; i ) {/ * select the text style, direction, and size * / settextStyle (Triplex_Font, Horiz_Dir, i); / * Create a Message String * / Sprintf (MSG, "Size:% D", i) ; / * Output the message * / Outtextxy (1, y, msg); / * Advance to the next text line * / y = textheight (msg);} / * clean up * / getch (); Closegraph (); Return 0;} function name: TextMode function: Set the screen into text mode usage: void textmode (int mode); program case: #include int main (void) {TextMode (BW40); CPRINTF ("ABC) "); getch (); TextMode (C40); CPRINTF (" abc "); getCh (); TextMode (BW80); CPrintf (" abc "); getCh (); TextMode (C80); CPrintf (" abc ") getCH (); TextMode (MONO); CPRINTF ("abc"); getch (); returnography;} function name: TextWidth function: Return to a string width usage with pixels: int FAR TEXTWIDTH (Char Far * TextString Application: #incl Ude #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int X = 0, y = 0; INT i; char msg [80]; / * 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 * /} y = getmaxy () / 2;

SetTextJustify (Left_Text, Center_Text); for (i = 1; i <11; i ) {/ * select the text style, direction, and size * / settextStyle (Triplex_Font, Horiz_Dir, i); / * Create a Message String * / Sprintf (MSG, "SIZE:% D", I); / * Output the Message * / Outtextxy (x, y, msg); / * Advance to the end of the text * / x = textwidth (msg); / * CLOAN UP * / GETCH (); closegraph (); return 0;} function name: TIME function: Take a day time usage: logn time (long * tloc); program: #include #include #include int main (void) {TIME_T T; T = Time (NULL); Printf ("THE NUMBER OF Seconds Since January 1, 1970 / I% LD", T); Return 0;} function name: TMPFILE function: Take a temporary file with binary: file * tmpfile (void); program example: #include #include int main (void) {file * Tempfp; tempfp = tmpfile (); if (tempfp) Printf ("temporary file created / n"); Else {Printf ("Unable to create temporary file / n"); exit (1);} return 0;} function name : TMPNAM function: Create a unique file name usage: char * tmpnam (char * sptr); program case: #include int main (void) {char name [13]; tmpnam (name); Printf "Temporary Name:% S / N", NAME); RETURN 0;} function Name: TOLOWER function: Convert characters to lowercase letters: int TOLOWER (INT C); program: #include #include #include int main (void) { INT Length, I; Char * String = "this is a string"; length = string; for (i = 0; i #include < Stdio.h> #include int main (void) {INT Length, i; char * string = "this is a string"; length = strlish (string); for (i = 0; i

TouPper (String [i]);} Printf ("% s / n", string); return 0;} function name: tzset function: UNIX time compatible function method: void tzset (void); program: #include

% D, Next Char in buffer =% C / N ", I, getch ()); return 0;} function name: Unixtodos function: convert date and time into a DOS format: Void Unixtodos (long utime, struct date * DatePtr, Struct Time * TimePtr); Question: #include #include char * month [] = {"-", "jan", "feb", "mar", "APR", "May", "Jun", "Jul", "AUG", "SEP", "Oct", "NOV", "DEC"}; # define seconds_per_day 86400l / * the number of seconds in one day * / struct date dt; struct time tm; int main (void) {unsigned long value * / getday's date and time * / getdate (& dt); gettime (& tm); Printf ("Today IS% D% S% D /1 "DT.DA_DAY, MONTH [DT.DA_MON], DT.DA_YEAR); / * Convert Date and Time To Unix Format (Number of SecondsSince Jan 1, 1970 * / VAL = Dostounix (& DT, & TM); / * Subtract 42 days Worth of Seconds * / Val - = (Seconds_Per_Day * 42); / * Convert Back to Dos Time and Date * / UnixTodos (Val, & DT, & TM); Printf ("42 Days AGO IT WAS% D% S%) D / N ", DT.DA_DAY, MONTH [DT.DA_MON], DT.DA_YEAR); RETURN 0;} Function Name: Unlink function: Delete a file method: int unlink (char * fileename); program: #include #include int main (void) {file * f P = fopen ("junk.jnk", "w"); int status; fprintf (FP, "JUNK"); status = access ("junk.jnk", 0); if (status == 0) Printf (" File exists / n "); ElsePrintf (" File Doesn't Exist / N); Fclose (FP); Unlink ("Junk.jnk"); Status = Access ("Junk.jnk", 0); IF (Status == 0) Printf ("File Exists / N"); ElsePrintf ("File Doesn't Exist / N); Return 0;} Function Name: UNLOCK Function: Release File Sharing Lock Usage: Int Unlock (Int Handle, Long OFFSET, Long Length;

#include #include #include #include int main (void) {Int Handle, Status; Long length; Handle = Sopen ("c : // //autoexec.bat ", o_rdonly, sh_denyno, s_iread); if (Handle <0) {Printf (" Sopen Failed / N "); EXIT (1);} length = filelength; status = lock (Handle , 0L, LENGTH / 2); if (status == 0) Printf ("Lock succeeded / n"); ElsePrintf ("Lock Failed / N"); status = unlock (handle, 0l, length / 2); if ( Status == 0) Printf ("Unlock successEDED / N"); ElsePrintf ("unlock failed / n"); close (Handle); return 0;} letter V start function function name: vfprintf function: send formatted output to first-class Medium use: int vfprintf (file * stream, char * format, va_list param); program case: #include #include #include file * fp; int vfpf (char * fmt, ...) {va_list argptr; int CNT; VA_START (Argptr, FMT); CNT = Vfprintf (FP, FMT, Argptr); VA_END (Argptr); Return (CNT);} int main (void) {INT Inumber = 30; float fnumr = 90.0; char string [4] = "abc"; fp = tmpfile (); if (fp == null) {PERROR ("tmpfile () call"; exit (1);} VFPF ("% D% F% S", Inumber, Fnumber, String; Rewi Nd (fp); FSCANF (FP, "% D% F% S", & Inumber, & FNumber, String); Printf ("% D% F% S / N", Inumber, FNumber, String; Fclose (FP); Return 0;} function name: vfscanf function: Formatting input from stream: int vfscanf (file * stream, char * format, va_list param); program: #include #include #include file * fp; int vfsf (char * fmt, ...) {va_list argptr; int CNT; VA_START (Argptr, FMT); CNT = VFSCANF (FP, FMT, Argptr); VA_END ( Argptr); Return (CNT);} int Main (void) {INUMBER = 30; float fnumber = 90.0; char string [4] = "abc"; fp =

TMPFile (); if (fp == null) {Perror ("tmpfile () call"; exit (1);} fprintf (fp, "% D% f% S / N", inumber, fnumber, string); ReWind (fp); VFSF ("% D% F% S", & Inumber, & FNumber, String); Printf ("% D% F% S / N", Inumber, FNumber, String); Fclose (FP); Return 0 } Function name: vprintf function: send formatted output to stdout: int vprintf (char * format, va_list param); program example: #include #include int VPF (char * FMT, ...) {va_list argptr; int CNT; VA_Start (argptr, format); cnt = vprintf (fmt, argptr); VA_END (Argptr); return (cnt);} int main (void) {int inumber = 30 FLOAT FNUMBER = 90.0; char * string = "abc"; VPF ("% D% F% S / N", Inumber, FNumber, String); Return 0;} function name: vscanf function: Format from STDIN Input usage: int vscanf (char * format, va_list param); program example: #include #include #include int vscnf (char * fmt, ...) { VA_List Argptr; int CNT; Printf ("Enter an INTEGER, A Float, And A String / (EGI, F, S,) / N"); VA_Start (Argptr, FMT); CNT = VSCANF (FMT, Argptr); VA_END (argptr); RETURN (CNT);} int main (void) {Int inumber; float fnumber; char string [80]; vscnf ("% D,% f,% S ", & Inumber, & FNumber, String); Printf ("% D% F% S / N ", Inumber, FNumber, String; Return 0;} function name: vsprintf function: send formatted output to string usage: int VSPrintf (Char * String, Char * Format, VA_LIST param); program example: #include #include #include char buffer [80]; int vspf (char * fmt) , ...) {va_list argptr; int CNT; VA_START (Argptr, FMT); CNT = VSPrintf (Buffer, FMT, Argptr); VA_END (Argptr); Return (CNT);} int main (void) {INUMBER = 30; float fnumr = 90.0; char string [4] = "abc"; VSPF ("% D% F% S", Inumber, FNumber, String); Printf ("% s / n", buffer; return 0;

} Function name: vsscanf function: Perform format input from the stream: int vsscanf (char * s, char * format, va_list param); program: #include #include #include char buffer [80] = "30 90.0 abc"; int Vssf (char * fmt, ...) {va_list argptr; int CNT; fflush (stdin); va_start (argptr, fmt); cnt = vsscanf (Buffer, FMT, Argptr); VA_END (Argptr); Return (CNT);} int main (void) {Int Inumber; float fnumber; char string [80]; VSSF ("% D% f% s", & inumber, & FNumber, String); Printf ("% D% f% S / N", inumber, fnumber, string; return 0;} letter W start function function name: WHEREX function: Return window horizontal cursor location usage: int WHEREX Void);: #include int main (void) {clrs (); gotoxy (10, 10); CPRINTF ("Current Location IS X:% D Y:% D / R / N", WHEREX (), wherey ()); getch (); return 0;} function name: WHEREY function: Return window vertical cursor location usage: int wherey (void); program: #include int main Void) {clrs (); gotoxy (10, 10); CPRINTF ("Current Location IS X:% D Y:% D / R / N", WHEREX (), wherey ()); getCh (); Return 0; } Function Name: Window Features: Defining Activity Text Mode Window Usage: Void WINDOW (Int Left, Int Top, Int Right, Int Bottom); Procedure: #nclude int main (void ) {WINDOW (10, 10, 40, 11); TextColor (Black); TextBackground (White); CPrintf ("this is a test / r / n"); return 0;} function name: Write function: Write one Usage: int Write (int Handel, Void * BUF, INT NBYTE); program example: #include #include #include #include #include #include int main (void) {int Handle; char string [40]; int lay, res; / * create a file named "TEST. $$$" in The CurrentDirectory and write a string to it. if "Test. $$$" already exists, it will be overwritten. * / if ("Test. $$$", o_wronly | o_creat | o_trunc, s_iread | s_iwrite )) == - 1) {Printf ("

转载请注明原文地址:https://www.9cbs.com/read-96072.html

New Post(0)