Turbo C 2.0, Borland C ++ library function and use case [a-m]

xiaoxiao2021-03-06  42

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 (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); /. / FILETC (STITAM); / * 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); * / # 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: FileLength : Take the file length byte number: long filength; program example: #include #include #include #include int main Void) {INT HANDLE; Char BUF [11] = "0123456789"; / * CREATE A File Containing 10 Bytes * / Handle = Open ("Dummy.fil", O_CREAT);

Write (Handle, BUF, Strlen (BUF)); / * Display the size of the file * / printf ("File Length in Bytes:% LD / N", FileLength); / * Close THE * / CLOSE (Handle);} function name: Fillellipse function: Draw and populate an ellipse usage: Void Far Fillellipse (int X, int y, int xradius, int yradius); program: #include # INCLUDE int main (void) {Int gDriver = detect, gmode; int xcenter, ycenter, i; infitgraph (& gdriver, & gmode, "); xcenter = 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: Painting and populate a polygon usage: Void Far FillPoly (int Numpoints, int far * polypoints); program example: #include #include #include #include int main (void) {/ * Request Auto Detection * / INT GDRIVER = Detect, Gmode, ErrorCode; INT I, MAXX, MAXY; / * OUR POLYGON ARRAY * / INT POLY [8]; / * Initialize Graphics, Local variables * / initgraph (& gdriver, & gmode, ""); / * read results = graphres * / errorcode = graphres Ult (); if (ErrorCode! = GROK) / * An error acrrred * / {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 . * / poly [6] = maxX / 2; poly [7] = maxY / 2; / * loop through the fill pattern * / for (i = Empty_fill; i

) {/ * set Fill Pattern * / setFillStyle (i, getmaxcolor ()); / * draw a filled polygon * / fixpoly (4, poly); getch ();} / * clean up * / closegraph (); return 0 } Function name: FindFirst function: Search disk directory; acquire file usage of the next matching FindFirst mode: int FindFirst (char * pathname, struct ffblk * ffblk, int attrib); program case: / * Findfirst Example * / # include #include int main (void) {struct ffblfblk; int done; printf ("Directory Listing of *. * / N"); DONE = FINDFIRST ("*. *", & ffblk , 0); While (! ","% S / n ", ffblk.ff_name); DONE = FINDNEXT (& FFBLK);} return 0;} function name: FindNext function: Search disk directory; get the next match FindFirst mode file usage: int FindNext (struct ffblk * ffblk; program: / * 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;} return 0;} function name: floodfill function: Fill a bounded area: Void Floodfill (int x, int y, int border); program case: #include #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 results = graphresult (); if (errorcode! = grok) / * an error ocurred * / {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 * / reccTangle (0, 0, Maxx, Maxy); / * DRAW SOME CIRCLES * / CIRCLE (MAXX / 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 (); / * Floodfill (2, 2, getmaxcolor (); / * clean up * / getch (); closegraph (); return 0;} function name: floor function: Down In-use: Double Floor (double x); program: #include #include int main (void) {double number = 123.54; double down, up; down = floor (number); 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 function: Clear all buffer usage: int flushall (void); program case: #include int main (void) {file * stream; / * create 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: f MOD function: calculate X-to-Y size, ie X / Y's remainder usage: double fmod (double x, double y); program: #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); program: #nclude #include # INCLUDE int main (void) {char s [maxpath]; char dir [maxdir]; 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 seat elems * / strcpy (file, "data"); strcpy (ext, ". txt") Fnmerge (S, Drive, Dir, File, EXT); / * Merge Everything Into One String * / PUTS (S); / * Display results: FOPEN function: FOPEN function: Open a flow method: File * fopen (Char * filename, char * type); program example: #include #include #include int main (void) {char * s; char driving [CHAR DRIVE MaxDrive]; char file [maxfile]; char file [maxext]; int flag; s = getenv ("comspec"); / * get the comspec environment parameter * / flags = fnsplit (s, drive, DIR, 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 (Flags & Extension) Printf (" / textension:% s / n ", EXT); RETURN 0;} function name: fprintf function: Transfer formatted output to a stream Usage: int FPrintf (file * stream, char * format [, argument, ...]); example: / * Program To Create backup of theautoexec.bat file * / # include int main (void) {file * in, * out; if ((in = fopen ("// autoexec.bat", "RT")) == null) {fprintf (stderr, "Cannot Open INPUT /FILE./N "); Return 1;} IF ((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 Quantitative method: Unsigned fp_off (Void Far * Farptr); program case: / * 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) Medium-use method: int fputchar (char ch);: #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 into a stream Usage: int FPUTS (Char * String, File * Stream); Procedure: #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 Fread (Void * PTR, int size, int nitems, file * stream); program: #include #include int main (void) {file * stream; char msg [] = " t His is a test "; char buf [20]; IF (" "Dummy.fil", "W "))) == null) {fprintf (stderr, "cannot open out 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 the assigned 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" , / * 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 O / Paragraphs 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: Put a double precision break down Method for mandade: Double frexp (Double Value, INT * EPTR); program example: #include #include int main (void) {Double Mantissa, Number; int exponent; numer = 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: Perform format input from one stream: int Fscanf (file * stream, char * format [, argument ...]); program case: #include #include int main (void) {INT I; Printf ("INPUT AN INTEGER:");

/ * Read an INTEGER from thisStandard 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: file pointers for repositioning stream: int FSeek (file * stream, long offset, int fromwhere) Draft: #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 / ", FileSize (stream); Return 0;} long filesize (file * stream) {Long Curpos, Length Curpos = ftell (stream); FSeek (stream, 0l, seek_ek; length = ftell (stream); fseek (stream, curpos, seek_set); return length;} function name: fSETPOS function: file pointer on positioning stream : INT FSETPOS (File * Stream, Const fpos_t * pOS); Questions: #include #include void showpos (file * stream); 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, & file POS); / * 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 POINTERPSITION 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); program case: #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), & statbuf); fclose (stream); / * display the information returned * / if (statbuf.st_mode & S_IFCHR) 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: ftell function: Returns the current file pointer method: long ftell (file * stream); program case: #include int main (void) {file * stream; stream = fopen ("My File.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 ((stream = fopen ("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: conversion floating point number Complex: 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: getArccoords function: acquiring the last call ARC coordinate usage: Void Far GetArccoRDS (Struct ArccoordStype Far * ArccoRDS); : #include #include #include #include int main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode Steut ArccoordStype Arcinfo; int MIDX, Midy; int standle = 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.yend; / * 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: Returns aspect ratio usage of current graphics mode: Void Far Getaspectratio (int Far * XASP, INT FAR * 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 (); / * 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 (); setaspectratiotio (XASP / 2, YASP); Circle (MIDX, MIDY, 100); getCh (); / * draw narrow circle * / clearden (); setaspectratio (XASP, YASP / 2) Circle (MIDX, MIDY, 100); / * CLOAN UP * / GETCH (); closegraph (); return 0;} function name: getBKCOLOR Function: Return to Current Background Color Usage: Int Far getBkcolor (Void); #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 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 (); / * 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); / * CLOAN UP * / GETCH (); Closegraph (); Return 0;} Function Name: Getc Function: Take a character from the stream: int GETC (File * stream); program example: #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 Usage: int getcbrk (void); program case: #include #inc Lude 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 from the console to take a character usage: 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: Read characters from STDIN Usage: int GETCHAR (VOID); Questions: #include int main (void) {Int C; / * Note That getchar kets from stdin andis line buffered; this means it willnot Return Until You Press ENTER. * / while (c = getchar ())! = '/ n') Printf ("

% C ", c); return 0;} function name: getChe function: Take the character 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 to 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 results = graphresult (); / * an error er cc {(erroorcode! = grok) {printf (" graphics error:% s / n ", GrapherrorMsg (" 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 * / setxtjustify (center_text, center_text); / * get the current drawing colo R * / 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) ;: #Include #include #include char * current_directory (char * path) {structure (path, "x: //"); / * Fill String With form of response: x: / * / path [0] = 'a' getDisk (); / * replace 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 the current work directory usage: char * getcwd (char * buf, int N); program example: #include #include int Main (void) {Char Buffer [MAXPATH]; GetCwd (Buffer, MaxPath); Printf ("The Current Directory IS:% S / N", Buffer; Return 0;} Function Name: getDate Features: Take DOS Date Usage: Void getDate * DateBLK; program case: #include #include int main (void) {struct date d; getdate (& D); Printf ("The current year 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 features: Back 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, erroorcode; int i; / * structure for return Palette Copy * / Struct Palette type 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 (); closegraph (); return 0;

} Function name: getDFree function: Take disk free space usage: void getDfree (int drive, struct dfree * DFreeP); program: #include #include #include # Include int main (void) {structure 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_bsec * (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); program: #include # Include int main (void) {int Disk; disk = getDisk () 'a'; Printf ("THE CURRENT DRIVE IS:% C / N", Disk); Return 0;} function name: GetDrivername Function: Returns a string pointer usage containing the current graphics driver name: char * getDrivename (void); program: #include #include #include #include < conio.h> int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; / * stores the device driver name * / char * drivername; / * initialize graphics and local variables * / in ITGRAPH (& gDriver, & gmode, "); / * read results = 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);} setColor (GetMaxColor ()); / * 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 * / outtextxy (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); program: #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: From Environment Take a string method: Char * GetENV (Char * Envvar); Question: #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: highvideo function: Select high brightness text characters Usage: void highvideo (void); program Example: #include int main (void) {clrs CR (); lowvideo (); cprintf ("low intersity text / r / n"); highvideo (); gotoxy (1, 2); cprintf (" High intensity text / r / n "); return 0;} function name: HYPOT function: calculate the long usage of the right angle triangle: 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 start function function name: Imagesize Features: Returns the byte number required for Save Image Images: Unsigned Far ImageSize (int include #include #include #define arrow_size 10void #include #define arrow_size 10void draw_arrow (int x, int y); int main (void) {/ * request autodetection * / 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 ispessed * / 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 * Pathtodriv ER;: #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 INP (INT Protid);

Sample example: #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 idlline usage in the text window: Void Insline (Void); program case: #include int main (void) {ClrsCr (); 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 T) 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); CHINCLUDE #include #include #include / * function prototypes * / int huge detectega (void); void checkerrors (void); int main (void) {Int gDriver, gmode; / * install A User W ritten 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 anyinitialization 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: Install font file (CHR) not embedded in BGI system: int Far InstallUserFont (Char Far * Name); program: #include #include #include #include / * function prototype * / void checkerrrs (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 <

DOS.H> #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 INT86X (int INTR_NUM, UNION Regs * INSEGS, UNION Regs * Outregs, Struct Sregs * segregs); Questions: #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); #include #include / * deletes file name; returns 0 on success * / 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 INTDDOSX (Union Regs * INREGS, Union Regs * Outregs, Struct Sregs * Segregs; program example: #include #include / * deletes file name;

Returns 0 on success * / 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 Was 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]); : #include #include #include int main (void) {int stat; / * use func 8 to determine if the default drive isremovable * / stat = ioctl (0 , 8, 0, 0); "DRIVE% C Is Removable./N", getDisk () 'a'); ElsePrintf ("Drive% C Is Not Removable./N", GetDisk () 'A'); RETURN 0;} function name: isatty function: Check device type usage: int isatty (int Handle); program case: #include #include int main Void) {int Handle; Handle =

Fileno (STDPRN); 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 case: #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;} K start function function name: KBHIT function: Check the currently pressed key method: int KBHIT (VOID); program: #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 to reside usage: void keep (int status, int size); Example of program:.. / *** 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 form of paragraphs May Notnecessarily Work in All Cases. Use withcare! Terminate Stay Re sident (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 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 start function function name : LABS Function: Delivering Absolute Use: Long Labs (Long N); Procedure: #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 #includ E int main (void) {double value; double x = 2; / * ldexp raise 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 Rails, Renewers and Wait: LDIV_T LDIV (Long Lunumer, Long Ldenom); : / * 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: execution linear search: void * lfind (void * key, void * base, int * NELEM, INT WIDTH, INT) * FCMP) ()); example: #include #include

INT COMPARE (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) (int)) Compare); if (Result) Printf ("Number% D Found / N", Key); ElsePrintf ("Number% D Not Found / N", Key); Return 0;} Function Name: LINE Function: Painting in the specified two-point painted Line usage: Void Far Line (int X0, int y0, int x1, int y1); program: #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 result of initialization * / Errorcode = graphresult (); / * an error er (errorcode! = grok) {Printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("Press any key to halt:") Getch (); exit (1);} setColor (GetMaxColor ()); xmax = getmaxx (); ymax = getMaxy (); / * draw a diagonal line * / line (0, 0, xmax, ymax); / * Clean Up * / Getch (); closegraph (); return 0;} function name: LineRel function: Painting from the current location (CP) to the CP with CP with a given distance of a differential distance: Void Far LineRel (int DX, INT DY); Data 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) { 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) * / Sprintf (MSG, "(% D,% D)", Getx (), getY ()); Outtextxy (20, 30, msg); / * draw a line to a point a relativedistance afth 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: Transition dates and times to structural usage: struct tm * localtime (long * clock); program case: #include #include #include int Main (void) {Time_t Timer; StructTM * TBLOCK; / * GETS TIME OF DAY * / TIMER = 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 have dos sh Are.exe loaded for * // * file locking to funn ("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 succeeded / n "); ElsePrintf (" unlock failed / n "); Close (Handle ); RETURN 0;} function name: log function: log function ln (x) usage: double log (double x); program case: #include #include int main (void) {Double Result;

Double x = 8.6872; Result = log (x); Printf ("THE NATURAL LO% LF IS% LF / N", X, Result); Return 0;} function name: log10 function: logarithmic function log usage: double LOG10 (Double X); Question: #include #include int main (void) {Double Result; double x = 800.6872; results = 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 subs ... / n"); subroutine (jumper); Return 0;} void subroutine (jmp_buf jumper) { LONGJMP (Jumper, 1);} function name: lowvideo function: Select low brightness character usage: void lowvideo (void); program: #include int main (void) {clrs (); highvideo (); CPrintf ("High Intesity Text / R / N"); LowVideo (); gotoxy (1, 2); CPrintf ("Low Intensity Text / R / N"); Return 0;} Function Name: Lrotl, _lrotl Features: Will No symbolic long-intensive left cycle shift Usage: unsigned long L Unsigned long Lvalue, int count; unsigned long _lrotl (unsigned long Lvalue, int count); program example: / * Lrotl Example * / # include #include int main (void) {UNSIGNED long value = 100; result = _lrotl (value, 1); Printf ("The value% lu rotated left one bit is:% lu rotated le / n", value, result); Return 0;} function name : 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: #include < stdio.h> #include int compare (int * x, int * y) {return (* x - * y);} int main (void) {int Array [5] = {35, 87, 46, 99, 12};

SIZE_T NELEM = 5; int key; int * result; key = 99; Result = LFIND (& Key, Array, & Nlem, SizeOf (int), (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.comwhere); program: #include #include #include #include #include int main (void) {Int Handle; char msg [] = "this is a test"; char ch; / * create a file * / handle = 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 until we hit EOF * / do {read (Handle, & Ch, 1); Printf ("% C", CH);} 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 < Process.h> int main (void) {char * str; / * alloca TE Memory for String * // * this will generate an error when associate * // * 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); Return 0;} function name: Matherr function: User-can modify mathematical error handler usage: int MatherR (Struct Exception * e);

Example: / * this is a user-defined Matherr Function That PreventSany Error Messages from Being Printed. * / # Include int match 1;} function name: Memccpy function: from Source Source Copy N bytes 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 = Memccpy (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 bytes of arrays: 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, U NSIGNED N); Question: #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 two Pre-N bytes of sches S1 and S2, ignore case sensor: INT MEMICMP (Void * S1, Void * S2, Unsigned N); program: #include #include 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 block byte usage: void * Memmove (Void * Destin, Void * Source, unsigned n); program: #include #include < STDIO.H> 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 the CH, S array size by n gived by N gives: void * MEMSET (Void * S, CHAR CH, UNSIGNED N); program 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 Features: Create a directory usage: int mkdir CHAR * PATHNAME); Question: #include #include #include #include int main (void ) {Int status; clrs (); status = mkdir ("ASDFJKLM"); (! "(" Directory Created / N "): (Printf (" Unable to create Directory / N "); getch (); SYSTEM ("DIR"); getch (); status = rmdir ("asdfjklm"); (! status)? ("Directory deleted / n"): ("Unable to delete Directory) Return 0;} function name: MkTemp function: establish a unique file name usage: char * mktemp (char * template); program case: #include #include int main (void) {/ * fname defines the Template for the Temporary 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 score into an index and masonry: Double MODF (Double Value, Double * iptr); program example: #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 bytes usage: void movedata (int segsrc, int offsrc, int segdest, int offdest, unsigned numbytes); Example program: #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) {char buf [80 * 25 * 2]; save_mono_screen (buf);} function name: MoveRel function: moving a relative distance usage of the current location (CP): Void Far MoveRel (int Dx, int DY); Data 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 accurred * / {Printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("

Press any key to halt: "); getCH (); exit (1); / * Terminate with an error code * /} / * Move 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 rectangle Regional Usage: INT MoveText (int ost, int int, int int, int bottom); program example: #include #include int main (void) {char * Str = "this is a test string"; clrs CR (); cPUTS (STR); getCh (); MoveText (1, 1, str), 2, 10, 10); getCH (); return 0;} function Name: MoveTo function: Move CP to (x, y) Usage: Void Far Moveto (int X, int y); 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 accurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an AN Error Code * /} / * Move The cp to location (20, 30) * / MoveTo (20, 30); / * Plot a Pixel At the cp * / putpixel (getX (), getY (), getmaxcolor ()) ;

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

New Post(0)