Function name: KBHIT function: Check the currently pressed key method: int KBHIT (VOID);
#include
INT main (void) {CPRINTF ("Press any key to contact:"); while (! kbhit ()) / * do nothing * /; cprintf ("/ r / na key was press ... / r / n" RETURN 0;}
Function name: Keep function: Exit and continue to reside: Void Keep (int status, int size);
/ *** NOTE:. This is an interrupt service routine You can NOT compile this program with Test Stack Overflow turned on and get an executable file which will operate correctly Due to the nature of this function the formula used to compute the number of. paragraphs may not necessarily work in all cases. Use with care! Terminate Stay Resident (TSR) programs are complex and no other support for them is provided. Refer to the MS-DOS technical documentation for more information. * / #include
/ * The clock tick interface interrupt * /
#define INTR 0x1C
/ * Screen Attribute (Blue on Grey) * /
#define attr 0x7900
/ * Reduce Heaplength and Stacklength To 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 Memory IS AT B800: 0000. For a monochrome system use b000: 000 * / screen = mk_fp (0xB800, 0);
/ * Increase the counter and keep it with 0 to 9 * / count ; count% = 10;
/ * Put the number on the screen * / screen [0] [79] = count '0' Attr;
/ * Call the old interface interrupt handler * / oldhandler ();
INT main (void) {
/ * Get the address of the current clock tick interface * / oldhandler = getvect (INTR);
/ * Install The New Interrupt Handler * / setVect (Intr, Handler);
/ * _Psp is the starting address of the program in memory. The top of the stack is the end of the program. Using _SS and _SP together we can get the end of the stack. You may want to allow a bit of saftey space to Insure That Enough Room Is Being Allocated IE: (_SS (_SP Safety Space) / 16) - _PSP) * / Keep (0, (_SS (_SP / 16) - _PSP); Return 0;} Function Name : kbhit function: Check the currently pressed key method: int KBHIT (VOID);
#include
INT main (void) {CPRINTF ("Press any key to contact:"); while (! kbhit ()) / * do nothing * /; cprintf ("/ r / na key was press ... / r / n" RETURN 0;}
Function name: Keep function: Exit and continue to reside: Void Keep (int status, int size);
/ *** NOTE:. This is an interrupt service routine You can NOT compile this program with Test Stack Overflow turned on and get an executable file which will operate correctly Due to the nature of this function the formula used to compute the number of. paragraphs may not necessarily work in all cases. Use with care! Terminate Stay Resident (TSR) programs are complex and no other support for them is provided. Refer to the MS-DOS technical documentation for more information. * / #include
/ * The clock tick interface interrupt * /
#define INTR 0x1C
/ * Screen Attribute (Blue on Grey) * /
#define attr 0x7900
/ * Reduce Heaplength and Stacklength To 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 Memory IS AT B800: 0000. For a monochrome system use b000: 000 * / screen = mk_fp (0xB800, 0);
/ * Increase the counter and keep it with 0 to 9 * / count ; count% = 10;
/ * put the number on the screen * / screen [0] [79] = count '0' attr; / * call the old interrupt handler * / ildler ();}
INT main (void) {
/ * Get the address of the current clock tick interface * / oldhandler = getvect (INTR);
/ * Install The New Interrupt Handler * / setVect (Intr, Handler);
/ * _Psp is the starting address of the program in memory. The top of the stack is the end of the program. Using _SS and _SP together we can get the end of the stack. You may want to allow a bit of saftey space to Insure That Enough Room Is Being Allocated IE: (_SS (_SP Safety Space) / 16) - _PSP) * / Keep (0, (_ss (_SP / 16) - _PSP); Return 0;}
Function Name: ImageSize Features: Returns the bytes required to save the bit image: UNSIGNED FAR ImageSize (int LEFT, INT TOP, INT RIGHT, INT BOTTOM);
#include
#include
#include
#include
#define arrow_size 10
Void Draw_arrow (int X, int y);
INT main (void) {/ * request autodtection * / int gDriver = detect, gmode, errorcode; void * arrow; int x, y, maxx; unsigned int size;
/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");
/ * read results = graphresult (); if (error (error) / * an error opcurred * / {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); / * Terminate with an error code * /}
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); lineerel (4 * arrow_size, 0); lineerel (-2 * arrow_size, -1 * arrow_size); LineRel (0, 2 * arrow_size); LineRel (2 * arrow_size, -1 * arrow_size);}
Function Name: Initgraph Function: Initialization Graphics System Usage: Void Far Initgraph (int Far * GraphDriver, int Far * Graphmode, Char Far * Pathtodriver);
#include
#include
#include
#include
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode
/ * Initialize graphics mode * / initgraph (& gdriver, & gmode, "");
/ * Read results = graphResult (); 00 / 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 ());
/ * CLOAN UP * / GETCH (); closegraph (); return 0;}
Function Name: Inport Features: Enter the Usage from Hardware Port: INT INP (INT Protid);
#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 Features: Insert an empty line method in the text window: Void Insline (Void);
#include
INT main (void) {clrs (); CPrintf ("INSLINE INSERTS An Empty Line In The Text Window / R / N"); CPrintf ("At The Cursor Position Using The Current Text / R / N"); CPRINTF (" Background Color. All lines below the Empty One / R / N "); CPRINTF (" Move Down One Line and The Bottom Line Scrolls / R / N "); CPRINTF (" Off the bottom of the window./r/n " CPRINTF ("/ R / NPRESS ANY Key to Continue:"); Gotoxy (1, 3); getCh (); insol (); getch (); return 0;} function name: installUserDriver function: Installation device driver To the BGI device driver table Usage: Int Far InstallUserDriver (CHAR FAR * NAME, INT (* Detect));
#include
#include
#include
#include
/ * function prototypes * / int huge detectega (void); Void CheckerRors (void);
Int main (void) {Int gdriver, gmode;
/ * Install a User Written Device Driver * / GDriver = InstallUserDriver ("EGA", Detectega);
/ * Must force Use of detection routine * / gdriver = detect;
/ * check for any installation errors * / checkerrors ();
/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");
/ * Check for anyinitizance error * / checkerrors ();
/ * Draw a line * / line (0, 0, getmaxx (), getmaxy ());
/ * CLOAN 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 erroorcode
/ * 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) without embedding BGI system: int Far InstallUserFont (Char Far * Name);
#include
#include
#include
#include
/ * function prototype * / void checkerrors (void);
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode; int midx, mid;
/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");
MIDX = getmaxx () / 2; Midy = getMaxy () / 2;
/ * Check for anyinitizance error * / 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!");
/ * CLOAN UP * / GETCH (); closegraph (); return 0;}
/ * Check for and report any graphics errors * / void checkerrors (void) {int erroorcode
/ * 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 Features: Universal 8086 Soft Interrupt Interface Usage: INT INT86 (INT INTR_NUM, Union Regs * INREGS, Union Regs * Outregs);
#include
#include
#include
#define video 0x10
Void 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, ® S, ®S);
INT main (void) {clrs (); MoveToxy (35, 10); Printf ("Hello / N"); return 0;} function name: int86x function: General 8086 Soft Interrupt Interface Usage: int rt86x (int INTR_NUM, Union Regs * INSEGS, UNION Regs * Outregs, Struct Sregs * Segregs;
#include
#include
#include
INT main (void) {char filename [80]; union regs inregs, outregs; structure 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: General DOS interface usage: int Iion Regs * INREGS, Union Regs * Outregs);
#include
#include
/ * DELETES FILE Name; RETURNS 0 On Success, Nonzero On Failure * / INT Delete_file (Char Near * filename) {UNION Regs Regs; int RET; regs.h.ah = 0x41; / * delete file * / regs.x. DX = (unsigned) filename; RET = INTDOS (®S, ®S);
/ * 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"); Else Printf ("not able to DELETE NOTEXIST. $$$ / n "); Return 0;}
Function Name: INTDOSX Features: Universal DOS Interrupt Interface Usage: Int INTDOSX (Union Regs * INREGS, UNION Regs * Outregs, Struct Sregs * Segregs);
#include
#include
/ * deletes file name; returns 0 on success, nonzero on failure * / int delete_file (char far * filename) {UNION Regs Regs; struct Sregs Sregs; int Ret; regs.h.ah = 0x41; / * delete file * / Regs.x.dx = fp_off (filename); SREGS.DS = fp_seg (filename); RET = INTDOSX (®S, ®S, & SREGS);
/ * if carry flag is set, there is an error * / return (regs.x.cflag? RET: 0);} int main (void) {int err; err = delete_file ("NOTEXIST. $$$"); IF (! ERR) Printf ("Able to delete Notexist. $$ / n"); Else Printf ("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);
#include
#include
#include
#include
#define cf 1 / * carry flag * /
INT main (void) {char directory [80]; structure 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, ®); 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 is removable * / stat = ioctl (0, 8, 0, 0); if (! stat) printf ("Drive% C Is Removable./N", getDisk () 'A'); Else Printf ("Drive% C Is Not Removable./N", getDisk () 'A'); Return 0;}
Function Name: ISATTY function: Check device type usage: int isatty (int Handle);
#include
#include
INT main (void) {int Handle;
Handle = fileno (stdprn); if (isatty (Handle) Printf ("Handle% D Is A Device Type / N", Handle); Else Printf ("Handle% D Isn't A Device Type / N", Handle) Return 0;}
Function name: ITOA function: convert an integer into a string usage: char * itoa (int value, char * string, int RADIX);
#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;} Function Name: HARDERR Function: Creating a hardware error handler Usage: Void Harderr INT (* fptr) ()); program: / * This Program Will Trap Disk Errors and prompt the user for action. Try Running It with no disk in drive A: to invoke its functions. * / #include
#include
#include
#define ignore 0
#define retry 1
#define Abort 2
INT BUF [500];
/ * Define the Error Messages for Trapping Disk Problems * /
Static char * err_msg [] = {
"Write Protect",
"Unknown Unit",
"Drive Not Ready",
"Unknown Command",
"Data Error (CRC)",
"Bad Request",
Seek Error,
"Unknown Media Type",
"Sector not found",
"Printer Out of Paper",
"Write Fault",
"Read Fault",
"General Failure",
"reserved",
"reserved",
Invalid Disk Change
}
Error_win (char * msg) {int RetVal; CPUTS (MSG); / * Prompt for user to press, ignore * / while (1) {return = getCH (); if (Retval == 'A '|| RETVAL ==' a ') {RETVAL = Abort; Break;} if (Retval ==' R '|| RetVal ==' R ') {RETVAL = RETRY; Break;} if (Retval ==' i '|| Retval ==' I ') {RetVal = Ignore; Break;}} Return (Retval);} / * pragma warn -par reduces Warnings Which Occur Due to the Non Use of the parameters Errval, BP and Si To the Handler. * / #pragma Warn -Par Int Handler (int tent) {static char msg [80]; unsigned di; int drive; int erroorno; di = _di; / * if this is IS NOT A DISK ERROR THEN IT WAS Another Device Having Trouble * / IF (AX <0) {/ * Report The Error * / Error_WIN ("Device Error"); / * And return to the program directly Requesting Abort * / HardRetn (Abort } / * OtherWise IT WAS A Disk error * / drive = AX & 0x00FF; ErrorNO = DI & 0x00FF; / * Report Which Error IT WAS * / SPRINTF (MSG, "Error:% s on drive% C / R / Na) BORT, R) ETRY, I) GNORE: ", ERR _MSG [ErrorNo], 'A' Drive); / * Return to The Program Via DOS Interrupt 0x23 with Abort, Retry, or ignore as ignore (Error_WIN (MSG)); Return Abort;} # Pragma Warn Par Int Main (Void) {/ * Install Our Handler on The Hardware Problem Interrupt * / Harderr (Handler); CLRSCR (); Printf ("Make Sure The No Disk In Drive A: / N"); Printf ("Press ANY Key .... / N"); getCH (); Printf ("Trying to Access Drive A: / N"); Printf ("Fopen Returned% P / N", FOPEN ("A: Temp. DAT "," w ")); Return 0;
} Function name: HardResume function: hardware error handling function usage: void hardresume (int rescode); program case: / * This Program Will Trap Disk Errors and prompt the user for action. * / / * Try Running It with no disk in drive A: to invoke its functions * / # includ # include
#include
#define ignore 0 #define retry 1 #define Abort 2 int buf [500]; / * Define the error message for trapping disk problems * / static char * err_msg [] = {"Write Protect", "Unknown Unit", "Drive NOTY "," Unknown Command "," Data Error (CRC) "," Bad Request "," Seek Error "," Unknown Media Type "," Sector Not Found "," Printer Out of Paper "," Write Fault " , "Read Fault", "General Failure", "Reserved", "Reserved", "Invalid Disk change"}; error_win (char * msg) {int RetVal; CPUTS (MSG); / * Prompt for user to Press A KEY To Abort, retry, ignore * / while (1) {return = getch (); if (retval == 'a' || Retval == 'a') {RetVal = Abort; Break;} if (Retval == ' R '|| RetVal ==' R ') {RetVal = Retry; Break;} if (Retval ==' I '|| Retval ==' I ') {RetVal = Ignore; Break;}} retURN (RetVal); } / * pragma warn -par reduces warnings which occur due to the Non Use * / / / / * of the parameters Errval, BP and Si to the handler. * / #pragma warn -par Int Handler (int Errval, int Ax, int bp , int Si) {static char msg [80]; Unsigned di; int rou; di = _di; / * if this is not a disk error kil dam i (AX <0) {/ * report the error * / error_win ("Device Error "); / * and return to the program directly requesting Abort * / hardretn (abort);} / * Otherwise it Was a disk error * / drive = ax & 0x00ff; erroNO = DI & 0x00FF; / * Report Which Error IT WAS * / sprintf (MSG, "Error:% S on DRIVE% C / R / NA) BORT, R) ETRY, I) GNORE:", ERR_MSG [ErrorNo], '
A ' Drive); / * Return to the program via dos interrupt 0x23 with abort, retry * / / * or ignore as infut by the user. * / Hardresume (Error_WIN (MSG)); Return Abort;} #pragma Warn PAR INT Main (void) {/ * install outmler on the hardware proBLERRUPT * / HARDERR (Handler); CLRSCR (); Printf ("Make Sure The Is No Disk In Drive A: / N"); Printf ("PRESS any key .... / n "); getCH (); Printf (" Trying to Access Drive A: / N "); Printf (" Fopen Returned% P / N ", FOPEN (" A: Temp.dat ", "w")); RETURN 0;} function name: highvideo function: Select high brightness text characters Usage: void highvideo (void); program case: #includint main (void) {clrs (); 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 angle triangle Long usage: double hypot (double x, double y); program: #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;} : getModeRANGE Function: Take the pattern range of graphics drivers: Void Far getModeraNge (int graphDriver, int far * tent, int far * himode; program: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; int low, high; char mrange [80]; / * initialize graphics and local variables * / initgraph (& gdriver , & gmode, ""); / * read results = graphResult (); if (errorcode! = grok) / * an error occurred * / {printf ("graphics error:% s / n", grapherrormsg ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxY () / 2 ; / * get the mode range for this driver * / getModeRange (GDRIVER, & LOW, & HIGH); / * Convert mode Range info. INTO STRINGS * / SPRINTF (MRANGE, "This Driver Supports MODES% D ..% D", Low , / * Display the information * / settextjustify (center_text, center_text); Outtextxy (MIDX, MIDY, MRANGE); / * clean up * / getch (); closegraph (); return 0;} function name: getPalette function : Returns information about the current palette: Void Far getPalette (Struct PaletType Far * Palette); program: # include # include
#include
#include
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; struct pastettype pal; char psize [80], pval [20]; int i, ht; int y = 10; / * Initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error 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);} / * grab a copy of OF THE PALETTE * / GETPALETTE (& PAL); / * Convert Palette Info. INTO STRINGS * / SPRINTF (Psize, "The Palette Has% D / Modifiable Entries); / * Display THE Information * / OutTextxy (0 , y, psize); if (pal.size! = 0) {ht = textHeight ("w"); y = 2 * ht; Outtextxy (0, y, "Here the current / values:"); y = 2 * ht; for (i = 0; i {
Sprintf (PVAL,
"Palette [% 02D]: 0x% 02x", I,
Pal.colors [i]);
OutTextxy (0, Y, PVAL);
}
}
/ * CLOAN UP * / GETCH (); closegraph (); return 0;} function name: getPass function: read a password usage: char * getpass (char * prompt); program case: #include
INT main (void) {char * password; password = getpass ("INPUT A Password:"); CPRINTF ("THE Password IS:% S / R / N", Password); Return 0;} Function Name: getpixel function: Get the color usage of the specified pixel: int 4, int x, int y); example: #include
#include
#include
#include
#include
#define PIXEL_COUNT 1000 #define DELAY_TIME 100 / * in milliseconds * / int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int i, x, y, color, maxx, maxy, maxcolor , seed; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result 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);} Maxx = getmaxx () 1; maxy = getMaxy () 1; maxColor = getmaxcolor () 1; while (! kbhit ()) {/ * seed the random Number generator * / seed = random (32767); SRAND SEED); for (i = 0; i {
X = random (maxx);
Y = random (MAXY);
Color = random (maxcolor);
PUTPIXEL (X, Y, Color);
}
DELAY (DELAY_TIME); SRAND (SEED); for (i = 0; i
{
X = random (maxx);
Y = random (MAXY);
Color = random (maxcolor);
IF (color == getpixel)
Function name: Gets function: take a string usage from the stream: char * gets (char * string); program case: #include
INT main (void) {char string [80]; Printf ("Input A String:"); Gets (String); Printf ("THE STRING INPUT WAS:% S / N", String); Return 0;} Function Name : GetText function: Copy text on the text mode to the storage area: int GetText (int LEFT, INT TOP, INT Right, Int Bottom, Void * Destin); program: #include
CHAR BUFFER [4096]; int main (void) {INT i; clrs (); for (i = 0; i <= 20; i ) CPRINTF ("LINE #% D / R / N", I); GetText 1, 1, 80, 25, buffer; gotoxy (1, 25); CPrintf ("Press Any Key to Clear Screen ..."); getCH (); CLRSCR (); gotoxy (1, 25); CPRINTF "Press any key to restore ..."); getCH (); PutText (1, 1, 80, 25, buffer); gotoxy (1, 25); CPRINTF ("Press any key to quit ...") Getch (); return 0;} function name: GetTextinfo function: Display information usage for text mode: void gettextinfo (struct text_info * info); program case: #ncludint main (void) {struct text_info ti; getTextInfo (& Ti) ; CPRINTF ("Window Left% 2D / R / N", Ti.Winleft); CPRINTF ("Window Top% 2D / R / N", Ti.Wintop); CPRINTF ("Window Right% 2D / R / N", Ti.winright); CPrintf ("Window Bottom% 2D / R / N", Ti.winbottom; CPRINTF ("Attribute% 2D / R / N", Ti.attribute); CPrintf ("Normal Attribute% 2D / R / N ", Ti.Normattr); CPRINTF (" Current Mode% 2D / R / N ", Ti.Currmode); CPRINTF (" Screen Height% 2D / R / N ", Ti.ScreenHeight); CPrintf (" Screen Width% 2D / R / N ", Ti.Screenwidth; CPRINTF (" Current X% 2D / R / N ", Ti.curx); CPR INTF ("CURRENT Y% 2D / R / N", TI.CURY); RETURN 0;} Function Name: GetTextSettings Features: Returns information about current graphic text fonts: Void Far getTextSettings (Struct TextSettingstype Far * TextInfo); program Example: #include
#include
#include
#include
/ * The names of the fonts supported * / char * font [] = { "DEFAULT_FONT", "TRIPLEX_FONT", "SMALL_FONT", "SANS_SERIF_FONT", "GOTHIC_FONT"}; / * the names of the text directions supported * / char * dir [] = { "HORIZ_DIR", "VERT_DIR"}; / * horizontal text justifications supported * / char * hjust [] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT"}; / * vertical text justifications supported * / char * vjust [] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT"}; int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; struct textsettingstype textinfo; int midx, Midy, HT; CHAR FONTSTR [80], Dirstr [80], Sizestr [80]; Char HjustStr [80], VjustStr [80]; / * Initialize Graphics and Local Variables * / Initgraph (& gdriver, & gmode, ""); / * read results = graphresult (); if (error (error) / * an error opcurred * / {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; Midy = getMaxy () / 2; / * get information about current text settings * / gettext settings (& textinfo); / * Convert Text Information INTO STRINGS * / SPRINTF (Fontstr, "% s IS the text style. ", font [textinfo.font]); Sprintf (DIRSTR,"% s is the text direction. ", DIR [textInfo.direction]); sprintf (Sizestr,"% D is the text size. " , TextInfo.charsize; sprintf (hjuststr, "% s is the horizontal justification.", hjust [textInfo.horiz]); sprintf (vjuststr, "% s is the value vertical justification.", vjust [textInfo.vert];
/ * Display the information * / ht = textheight ( "W"); settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, fontstr); outtextxy (midx, midy 2 * ht, dirstr); outtextxy (midx, midy 4 * HT, Sizestr); OUTTEXTXY (MIDX, MIDY 6 * HT, HjustStr); Outtextxy (MIDX, MIDY 8 * HT, VjustStr); / * Clean Up * / GetCh (); Closegraph (); Return 0 } Function name: getTime function: acquired system time usage: void gettime (struct time * timep); program case: # include # include
INT main (void) {structure Time T; GetTime (& T); Printf ("THE CURRENT TIME IS: 2D:% 02D:% 02D.% 02D / N", T.Ti_HOUR, T.TI_MIN, T.TI_SEC, T. Ti_hund); Return 0;} function name: getVect function: acquired interrupt vector entrance usage: void interrupt (* getvect (int inter_num)); example: #include
#include
Void Interrupt get_out (); / * interrupt prototype * / void interrupt (* Oldfunc) (); / * interrupt function pointer * / int looping = 1; int main (void) {PUTS ("Press
TO TERMINATE ");
/ * save the old interface * / ildunc = getvect (5); / * install interrupt handler * / set_ / while (looping); / * restore to Original Interrupt Routine * / setVect (5, OldFunc); PUTS ("Success"); return 0;} void interrupt get_out () {looping = 0; / * Change global variable to get out of loop * /} function name: getverify function: Return to DOS check Sign Status Usage: INT GETVERIFY (VOID); program case: #include
#include
INT Main (Void) {if ("DOS Verify Flag IS ON / N"); Else Printf ("DOS Verify Flag IS Off / N); Return 0;} Function Name: GetViewSetting Features: Return Information usage for current view: Void Far getViewSettings (Struct ViewPortType Far * Viewport); program example: #include
#include
#include
#include
Char * clip [] = {"OFF", "on"}; int main (void) {/ * Request auto detection * / int gDriver = detect, gmode, errorcode; struct viewporttype viewinfo; int midx, midy, ht; char topstr [80], botstr [80], clipstr [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); if ( ERRORCODE! = GROK) / * An error Occurred * / {Printf ("graphics error:% s / n", grapherrormsg (erroorcode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1 ); / * terminate with an error code * /} midx = getmaxx () / 2; midy = getmaxy () / 2; / * get information about current viewport * / getviewsettings (& viewinfo); / * convert text information into strings * / sprintf (Topstr, "(% D,% d) is the Upper LEFT ViewPort Corner.", viewinfo.left, viewinfo.top); sprintf (botstr, "(% D,% d) is The Lower Right ViewPort Corner. ", viewinfo.right, viewinfo.bottom; sprintf (clipstr," clipping is turned% s. ", clip [viewinfo.clip]); / * Display the information @ * DISPLAY THE INFORTION * / Settextjustify (CENTER_TEXT, CENTER_TEXT); ht = textheight ( "W"); outtextxy (midx, midy, topstr); outtextxy (midx, midy 2 * ht, botstr); outtextxy (midx, midy 4 * ht, clipstr ); / * clen up * / getch (); closegraph (); return 0;} function name: GetW function: Take an integer usage from the stream: int GETW (File * STREM); program: # include # include
#define fname "Test. $$$" int main (void) {file * fp; int word; / * Place the word in a file * / fp = fopen (FNAME, "WB"); if (fp == null ) {Printf ("ERROR Opening File% S / N", FNAME); exit (1);} Word = 94; PUTW (Word, FP); if (FERROR (FP)) Printf ("Error Writing to file / n "); Else Printf (" successful write / n "); fclose (fp); / * reopen the file * / fp = fopen (FNAME," RB "); if (fp == null) {Printf (" Error Opening File% S / N ", FNAME); exit (1);} / * extract the word * / word = getw (fp); if (FP)) Printf (" Error Reading File / N "); Else Printf ("Successful Read: Word =% D / N", Word); / * Clean Up * / Fclose (FP); Unlink (FNAME); Return 0;} Function Name: Getx Features: Returns the X coordinate usage of the current graphics location : Int Far getx (void); program: # 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 the screen center point * / moveto (getmaxx () / 2, getmaxy () / 2); / * CREATE A Message String * / Sprintf (MSG, "<- (% D,% d) is the here.", getX (), gety ()); / * Display the message * / OutText (msg); / * Clean up * / getch (); closegraph (); return 0;} function name: getY function: Returns the y coordinate usage of the current graphics location: int Far gety (void); program case: #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 the screen center point * / moveto (getmaxx () / 2, getmaxy () / 2); / * CREATE A Message String * / Sprintf (MSG, "<- (% D,% d) is the here.", getX (), gety ()); / * Display the message * / OutText (msg); / * Clean Up * / getch (); closegraph (); return 0;} function name: GMTIME function: Convert date and time to GMT Time (GMT) Usage: StructTM * GMTIME (long * clock); # include # include
#include
#include
/ * Pacific Standard Time & Daylight Savings * / Char * Tzstr = "Tz = PST8PDT"; int main (void) {TIME_T T; StructTM * GMT, * Area; Putenv (Tzstr); tzset (); T = TIME NULL); Area = localtime (& T); Printf ("Local Time IS:% S", Asctime (area)); GMT = GMTIME (& T); Printf ("GMT IS:% S", ASCTIME (GMT)); Return 0;} function name: gotoxy function: Set the cursor usage in the text window: Void gotoxy (int x, int y); example: #include
INT main (void) {clrs (CLRSCR (); gotoxy (35, 12); cprintf ("Hello World"); getch (); return 0;} function name: gotoxy function: Set cursor usage in text window: void gotoxy ( INT X, int y); example: #include
INT main (void) {clrs CL (); gotoxy (35, 12); CPrintf ("Hello World"); getch (); return 0;} function name: graphdefault function: Reset all graphics settings for their default Usage: Void Far GraphDefaults (Void);
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int maxx, maxy; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, "c: // bor // Borland // bgi "); / * read result = graphResult (); if (errorcode! = Grok) / * an error occurred * / {printf (" graphics error:% s / n ", grapherrormsg ErrorCode); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} maxx = getmaxx (); maxy = getMaxy (); / * Output Line with non-default settings * / setline, 0, 3); line (0, 0, maxx, maxy); OutTextxy (Maxx / 2, Maxy / 3, "Before default value is rest."); getch ); / * restore default value for everything * / graphdefault (); / * clear the screen * / clearden (); / * Output line with default settings * / line (0, 0, maxx, maxy); OutTextxy (MAXX / 2, MAXY / 3, "After Restoring Default Values"); / * CLOAN UP * / GETCH (); Closegraph (); Return 0;} Function Name: GrapherrorMSG Function: Return to an Error String Pointer Usage: c Har * Far Grapherror (int errorcode);: # incrude # include
#include
#include
#define NONSENSE -50 int main (void) {/ * FORCE AN ERROR TO OCCUR * / int gdriver = NONSENSE, gmode, errorcode; / * initialize graphics mode * / initgraph (& gdriver, & gmode, ""); / * read result OF INITIALIZATION * / ErrorCode = graphResult (); / * if an error ire occurred, then output a * / / * descriptive error error message. * / if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N", GrapherrorMsg (ERRORCODE)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} / * draw a line * / line (0, 0, GetMaxx (), getMaxy ()); / * clean up * / getch (); closegraph (); return 0;} function name: graphresult function: Returns the last unsuccessful graphic operation error code usage: int Far GraphResult VOID);
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphResult (); if (ErrorCode! = GROK) / * An error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt:"); Getch (); exit (1); / * terminate with an error code * /} / * draw a line * / line (0, 0, getmaxx (), getmaxy ()); / * clean up * / getch () Closegraph (); RETURN 0;} function name: _Graphfreemem function: user-modified graphic storage area release function: void far _graphfreemem (Void Far * PTR, unsigned size); program case: #include
#include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; / * clear the text screen * / clrscr (); printf ( "Press any key to initialize graphics mode: "); getch (); clrscr (); / * initialize graphics and local variables * / initgraph (& gdriver, & gmode," "); / * read result of initialization * / errorcode = graphresult ();! if (errorcode = grOk ) / * an error occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; / * display a message * / settextjustify (center_text, center_text); Outtextxy (Midx, Midy, "Press Any Key to EXIT Graphics mode: "); / * clean up * / getch (); closegraph (); return 0;} / * called by the graphics kernel to allocate memory * / void far * fal _GraphgetMem (unsigned size) {printf (" _ graphgetMem Called to allocate% D Bytes./n ", size); Printf (" Hit any key: "); getCh (); printf (" / n "); / * allocat e memory from far heap * / return farmalloc (size);} / * called by the graphics kernel to free memory * / void far _graphfreemem (void far * ptr, unsigned size) {printf ( "_ graphfreemem called to free% d bytes. / N ", size); Printf (" Hit any key: "); getCh (); printf (" / n "); / * free Ptr from Far Heap * / farfree (PTR);} function name: _GraphgetMem function: User-can modify graphics storage area allocation function usage: void far * far _GraphgetMem (unsigned size); program case: # includ # include
#include
#include
#include
int main (void) {/ * request autodetection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; / * clear the text screen * / clrscr (); printf ( "Press any key to initialize graphics mode:" ); getch (); clrscr (); / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult ();! if (errorcode = grOk) / * an error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press Any Key to Halt:"); getCh (); exit (1); / * Terminate With an error code * /} midx = getmaxx () / 2; midy = getmaxy () / 2; / * display a message * / settextjustify (center_text, center_text); Outtextxy (Midx, Midy, "Press Any Key to EXIT graphics Mode: "); / * clean up * / getch (); closegraph (); return 0;} / * called by the graphics kernel to allocate memory * / void far * far _GraphgetMem (unsigned size) {printf (" _ graphgetMem Called TO Allocate% D Bytes./n ", size); Printf (" Hit any key: "); getCh (); printf (" / n "); / * allocate memory from far heap * / return farmalloc (size);} / * called by the graphics kernel to free memory * / void far _graphfreemem (void far * ptr, unsigned size) {printf ( "_ graphfreemem called to free% d bytes./ n ", size); Printf (" Hit any key: "); getch (); printf (" / n "); / * Function name: GCVT function: convert floating point number into a string method: char * GCVT (double Value, int ndigit, char * buf);
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: GenInterRupt function: Generate a soft interrupt usage: void geninterrupt INT INTR_NUM); Draft: # includ # include
/ * function prototype * / void writechar (char ch); int main (void) {clrsCr (); gotoxy (80, 25); WriteChar ('*'); getCh (); return 0;} / * Outputs a character at the current cursor position using the video BIOS to avoid the scrolling of the screen when writing to location (80,25) * / void writechar (char ch) {struct text_info ti;. / * grab current text settings * / gettextinfo (& ti ); / * interrupt 0x10 sub-function 9 * / _ah = 9; / * character to be output * / _al = ch; _BH = 0; / * video page * / _bl = ti.attribute; / * video attribute * / _CX = 1; / * repetition factor * / geninterrupt (0x10); / * Output the char * /} function name: getArccoords function: get the last call ARC coordinate usage: Void Far getArccoords (Struct ArccoordStype Far * ArccoRDS); program Example: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; struct arccoordstype arcinfo; int midx, midy; int stangle = 45, endangle = 270; char sstr [80], estr [80] ; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read 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; / * Draw arc and get coordinates * / setColor ()); Arc (MIDX, Midy, Stangle, Endangle, 100); GetArccoords (& ArcInfo); / * Convert Arc Information INTO STRINGS * / SPRINTF (SSTR, "* - (% D,% D)", arcinfo.xstart, arcinfo.ystart; sprintf (estr, "* - (% D,% d)", arcinfo. Xend, Arcinfo.Ynd; / * Output the arc information * / OutTextxy (arcinfo.xstart, arcinfo.ystart, sstr); Outtextxy (arcinfo.xend, arcinfo.Ynd, estr); / * Cl EAN UP * / GETCH (); Closegraph (); Return 0;} Function Name: Getaspectratio function: Return to the current graphic mode aspect ratio usage: Void Far getaspectratio (int Far * XASP, INT FAR * YASP); program case: # 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 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 ()) ; / * Get Current Aspect Ratio Settings * / GetASpectratio (& XASP, & YASP); / * Draw Normal Circle * / Circle (MIDX, MIDY, 100); getCh (); / * Draw Wide Circle * / Clearden (); setaspectratio XASP / 2, YASP; Circle (MIDX, MIDY, 100); getCh (); / * Draw narrow circle * / clearden (); setaspectratio (XASP, YASP / 2); Circle (MIDX, MIDY, 100); / * Clean Up * / getch (); closegraph (); return 0;} function name: getBKCOLOR Function: Return to Current Background Color Usage: Int Far getBkcolor (Void); program case: # includ # 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: #includint main (void) {char CH; Printf ("INPUT A Character:"); / * Read a Character from the standard input stream * / ch = getc (stdin); Printf ("The Character Input WAS: '% C' / N", CH); Return 0;} function name: getcbrk function: Get control_break settings: int getcbrk (void); program case: #include
#include
INT Main (Void) {IF ("CNTRL-BRK FLAG IS ON / N"); Else Printf ("CNTRL-BRK FLAG IS OFF / N"); return 0;} function name: getch function : From the console without retrieving a character usage: int getch (void); program case: #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 streams: int getchar (void); program case: #includeint main (void) {INT C; / * Note That getchar {inclom stdin and is line buffered; this means it will not return Until You press Enter. * / while ((c = getchar ())! = '/ n') Printf ("% c", c); return 0;} function name: getChe function: Take the character from the console (bring back Usage: int GetChe (void); example: #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 features: Return to the current line color usage: int Far getColor (Void); program case: #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 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 drawing color * / color = getcolor (); / * convert color value into a string * / itoa (color , ColName, 10); STRCAT (ColName, "Is The Current Drawing Color); / * Display A Message * / Outtextxy (MIDX, MIDY, ColName); / * Clean Up * / GetCH (); Closegraph (); Return 0;} function name: getCurdir function: Take the current directory usage of the specified drive: int GetCurdir (int drive, char * direc); program: # include # inclu de
#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 Current Work Directory Usage: Char * GetCwd (CHAR * BUF, INT N); Project: #include
#include
Int main (void) {char buffer [maxpath]; getCwd (Buffer, Maxpath); Printf ("The Current Directory IS:% S / N", Buffer; Return 0;} Function Name: getDate Features: Take DOS Date Usage : void getdate (struct * dateblk); program: # 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 function: return palette definition structure usage: struct pasteType * Far getDefaultPalette (void); Example: #include
#include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int i; / * structure for returning palette copy * / struct palettetype far * pal = (void *) 0; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); / * an error occurred * / if (! errorcode = grOk) {printf ( "Graphics error: % S / N ", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getch (); / * Terminate with an error code * / exit (1);} setColor ()); / * RETURN A POINTER TO THE DEFAULT PALETTE * / PAL = getDefaultPalette (); for (i = 0; i <16; i ) {printf ("Colors [% D] =% D / N", I, PAL-> Colors [I]); getCH ();} / * clen up * / getch (); closegraph (); return 0;} function name: getDisk function: Take the current disk drive number: int GETDISK (Void); : #include
#include
INT main (void) {Int Disk; disk = getDisk () 'a'; Printf ("THE CURRENT DRIVE IS:% C / N", Disk; Return 0;} Function Name: getDrivername Features: Back to point to the current String pointer usage of graphics driver name: char * getDriveName (void); program case: #include
#include
#include
#includeint main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; / * stores the device driver name * / char * drivername; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode , ""); / * read results = graphresult (); / * an error er c ({printf ("Graphics Error:% S / N", Grapherror (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 a disk transfer address usage: char far * getdta (void); program case: #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 the environment Take a string method: char * getenv (char * envvar); program case: #include
#include
INT main (void) {char * s; s = getenv ("comspec"); / * get the comspec environment parameter * / printf ("Command Processor:% S / N", S); / * DISPLAY COMSPEC Parameter * / Return 0;} function name: getfat, getfatd function: Take file allocation table information usage: void getfat (int drive, struct fatinfo * fatblkp); program case: #include
#include
INT main (void) {struct Fatinfo Diskinfo; INT FLAG = 0; Printf ("Please INSERT Disk in Drive A / N"; getChar (); getfat (1, & diskinfo); / * Get drive information * / printf (" / NDRIVE A: IS "); Switch ((unsigned char) diskinfo.fi_fatid) {case 0xfd: Printf (" 360k low density / n "); Break; Case 0xF9: Printf (" 1.2 meg high density / n "); Break; Default: Printf ("unformatted / n"); FLAG = 1;} if (! flag) {printf ("Sectors Per Cluster% 5D / N", Diskinfo.fi_SClus; Printf ("Number of Clusters% 5D / n ", diskinfo.fi_nclus; Printf (" Bytes Per Sector 5D / N ", Diskinfo.fi_Bysec);} Return 0;} Function Name: getFillPattern function: Copy user-defined fill mode to memory: Void Far GetFillPattern (Char Far * Upattern); Procedure: # include # include
#include
#include
INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int maxx, maxy; char pattern [8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x04} ; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); if (! errorcode = grOk) / * an error occurred * / {printf ("Graphics Error:% S / N", GrapherrorMsg (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} maxx = GetMaxx (); MAXY = getMaxy (); setColor (getMaxColor ()); / * select a user defined Fill Pattern * / setFillPattern (Pattern, getmaxcolor ()); / * Fill the screen with the pattern * / bar (0, 0, Maxx, Maxy; getch (); / * Get the current user defined Fill Pattern * / getfillpattern (pattern); / * alter the pattern we grabbed * / pattern [4] - = 1; pattern [5] - = 3; Pattern [6] = 3; Pattern [7] - = 4; / * Selectur new pattern * / setfillpattern (Pattern, getmaxcolor ()); / * Fill The Screen with The New Pattern * / Bar (0, 0, Maxx, Maxy); / * Clean Up * / getch (); Closegraph (); Return 0;} Function Name: GetFillSettings Features: Get information about current fill mode and fill color Usage: Void Far getFillSettings (Struct FillSettingstype Far * FillInfo);
#include
#include
/ The names of the fill styles supported * / char * fname [] = { "EMPTY_FILL", "SOLID_FILL", "LINE_FILL", "LTSLASH_FILL", "SLASH_FILL", "BKSLASH_FILL", "LTBKSLASH_FILL", "HATCH_FILL", " XHATCH_FILL "," INTERLEAVE_FILL "," WIDE_DOT_FILL "," CLOSE_DOT_FILL "," USER_FILL "}; int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; struct fillsettingstype fillinfo; int midx, midy ; char patstr [40], colstr [40]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, ""); / * read result of initialization * / errorcode = graphresult (); if (errorcode =! GROK / * An Error Occurred * / {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * terminate with an error code * /} midx = getmaxx () / 2; midy = getmaxy () / 2; / * get information about current fill pattern and color * / getfillsettings (& fillinfo); / * convert fill information into strings * / sprintf (PATSTR, "% s is the Fill Style.", FNAME [Fill info.pattern]); sprintf (colstr, "% d is the fill color.", fillinfo.color); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, patstr); outtextxy ( MIDX, MIDY 2 * TextHeight ("W"), colstr); / * clean up * / getch (); closegraph (); return 0;} function name: getftime function: Take a date and time usage: int Getftime INT HANDLE, STRUCT FTIME * ftimep);
INT main (void) {file * stream; struct ftime ft; IF ("Test. $$$", "WT")) == null) {fprintf (stderr, "cannot open output file./ N "); return 1;} getftime (Fileno (Stream), & ft); Printf (" File Time:% U:% U:% U / N ", ft.ft_Hour, ft.ft_min, ft.ft_tsec * 2) PRINTF ("File Date:% U /% U /% U / N", ft.ft_month, ft.ft_day, ft.ft_year 1980); fclose (stream); return 0;} function name: getGraphmode function: return Current Graphics Mode Usage: Int Far getgraphmode (void); program case: # include # include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy, mode; char numname [80], modename [80]; / * initialize graphics and local variables * / initgraph (& gDriver, & gmode, ""); / * read result = 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; / * get mode number and name strings * / mode = getgraphmode (); sprintf (Numname, "% d is the current mode number.", Mode); sprintf (MODENAME, "% s is the current graphics mode" , getmodename (mode)); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, numname); outtextxy (midx, midy 2 * textheight ( "W"), modename); / * Clean up * / getch (); closegraph (); return 0;} function name: getftime function: Take a date and time usage: int GetFTime (int Handle, Struct ftime * f TimeP); example: #include
#include
INT main (void) {file * stream; struct ftime ft; IF ("Test. $$$", "WT")) == null) {fprintf (stderr, "cannot open output file./ N "); return 1;} getftime (Fileno (Stream), & ft); Printf (" File Time:% U:% U:% U / N ", ft.ft_Hour, ft.ft_min, ft.ft_tsec * 2) PRINTF ("File Date:% U /% U /% U / N", ft.ft_month, ft.ft_day, ft.ft_year 1980); fclose (stream); return 0;} function name: getGraphmode function: return Current Graphics Mode Usage: Int Far getgraphmode (void); program case: # include # include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy, mode; char numname [80], modename [80]; / * initialize graphics and local variables * / initgraph (& gDriver, & gmode, ""); / * read result = 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; / * get mode number and name strings * / mode = getgraphmode (); sprintf (Numname, "% d is the current mode number.", Mode); sprintf (MODENAME, "% s is the current graphics mode" , getmodename (mode)); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, numname); outtextxy (midx, midy 2 * textheight ( "W"), modename); / * Clean up * / getch (); closegraph (); return 0;} function name: getImage function: save a bitmap of the specified area to the main memory: Void Far GetImage (int LEFT, INT T OP, int Right, Int Bottom, Void Far * Bitmap; program: #include
#include
#include
#include
#include
Void Save_Screen (Void restore_screen (Void Far * BUF [4]); int Maxx, Maxy; int main (void) {int GDriver = Detect, Gmode, ErrorCode; Void Far * PTR [4 ]; / * auto-detect the graphics driver and mode * / initgraph (& gdriver, & gmode, ""); erroorcode = graphresult (); / * check for any errors * / if (ErrorCode! = GROK) {Printf ("Graphics Error:% S / N ", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCh (); exit (1);} maxx = getmaxx (); maxy = getMaxY (); / * Draw An Image On The screen * / Rectangle (0, 0, Maxx, Maxy); Line (0, 0, Maxx, Maxy; Line (0, Maxy, Maxx, 0); Save_Screen (PTR); / * Save the Current screen * / getch (); / * pause screen * / clearden (); / * clear screen * / restore_screen (ptr); / * restore the screen * / getch (); / * pause screen * / closegraph (); Return 0;} void save_screen (Void Far * BUF [4]) {Unsigned size; int ystart = 0, Yend, Yincr, Block; Yincr = (MAXY 1) / 4; Yend = Yincr; Size = ImageSize (0, YSTART, MAXX, YEND; / * Get byte size of image * / for (BL OCK = 0; block <= 3; block ) {IF (BUF [block] = farmalloc (size) == null) {closegraph (); printf ("error: not enough holss Space in save_screen () ./ n "); exit (1);} getImage (0, ystart, maxx, ynd, buf [block]); YStart = YEND 1; Yend = yincr 1;}} void save_screen (Void Far * BUF [4] ) {Unsigned size; int ystart = 0, Yend, Yincr, Block; Yincr = (MAXY 1) / 4; Yend = Yincr; Size = Imagesize (0, YStart, Maxx, Yend); / * Get byte size of Image * / for (block = 0; block <= 3; block ) {IF ((BUF [block] = farmalloc (size)) == null) {closegraph (); printf ("
Error: Not enough Heap space in save_screen () ./ n "); exit (1);} getImage (0, ystart, maxx, yend, buf [block]); ystart = yend 1; Yend = YincR 1 }}} void restore_screen (Void Far * BUF [4]) {Int YStart = 0, Yend, Yincr, Block; Yincr = (MAXY 1) / 4; Yend = Yincr; For (block = 0; block <= 3 ; block ) {PUTIMAGE (0, ystart, buf [block], copy_put); farfree (buf [block]); ystart = yend 1; yend = yincr 1;}} function name: getLineSettings function: take the front line Model, Mode, and Width: Void Far getLineSettings (Struct Linesettingstype Far * LININFO): Sample: # include # include
#include
#include
/ * the names of the line styles supported * / char * LNAME [] = {"Solid_Line", "Dotted_Line", "Center_Line", "Dashed_Line", "Userbit_Line"}; int main (void) {/ * Request Auto Detection * / int gdriver = DETECT, gmode, errorcode; struct linesettingstype lineinfo; int midx, midy; char lstyle [80], lpattern [80], lwidth [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode , ""); / * read result = 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 * /} midx = getmaxx () / 2; midy = getMaxY () / 2; / * get information about current line settings * / getlinesettings (& lineinfo); / * convert line information into strings * / sprintf (lstyle, "% s is the line style.", lname [lineinfo.linestyle]); sprintf (lpattern, " 0x% x is the user-defined line pattern. ", Lineinfo.upattern; sprintf (lwidth,"% D IS . The line thickness ", lineinfo.thickness); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, lstyle); outtextxy (midx, midy 2 * textheight (" W "), lpattern ); OutTextxy (MIDX, MIDY 4 * TextHeight ("W"), LWIDTH); / * CLOAN UP * / GETCH (); Closegraph (); Return 0;} Function Name: GetMaxColor Function: Return to Function SetColor Maximum color value: int Far getMaxColor (void);
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; char colstr [80]; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, "" ); / * read results = graphresult (); if (erroorcode! = grok) / * an error occurred * / {printf ("graphics error:% s / n", grapherrormsg (errorcode)); Printf ("Press Any Key to Halt:"); getCH (); exit (1); / * terminate with an error code * /} midx = getmaxx () / 2; midy = getmaxy () / 2; / * Grab the color info and convert it to a string * / sprintf (colstr, "This mode supports colors 0 ..% d", getmaxcolor ());. / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, Midy, colstr); / * clean up * / getch (); closegraph (); return 0;} function name: getmaxx function: Return to the maximum x coordinate usage: int Far getMaxx (void); program: # include # Include
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; char xrange [80], yrange [80]; / * initialize graphics and local variables * / initgraph (& gdriver , & gmode, ""); / * read results = graphResult (); if (errorcode! = grok) / * an error occurred * / {printf ("graphics error:% s / n", grapherrormsg ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxY () / 2 ; / * Convert Max Resolution Values Into strings * / sprintf (xrange, "x values range from 0 ..% d", getmaxx ()); Sprintf (YRANGE, "Y VALUES RANGE FROM 0 ..% D", GetMax )))); / * Display the information * / setTextjustify (center_text, center_text); Outtextxy (MIDX, Midy, Xrange); Outtextxy (MIDX, Midy TextHeight ("W"), YRANGE); / * Clean Up * / getch ); closegraph (); return 0;} function name: getMaxY function: return screen's maximum y coordinate usage: int Far getMaxy (void);
#include
#include
int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; char xrange [80], yrange [80]; / * initialize graphics and local variables * / initgraph (& gdriver , & gmode, ""); / * read results = graphResult (); if (errorcode! = grok) / * an error occurred * / {printf ("graphics error:% s / n", grapherrormsg ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxY () / 2 ; / * Convert Max Resolution Values Into strings * / sprintf (xrange, "x values range from 0 ..% d", getmaxx ()); Sprintf (YRANGE, "Y VALUES RANGE FROM 0 ..% D", GetMax )))); / * Display the information * / setTextjustify (center_text, center_text); Outtextxy (MIDX, Midy, Xrange); Outtextxy (MIDX, Midy TextHeight ("W"), YRANGE); / * Clean Up * / getch ); return 0;} function name: getModename function: Returns a string pointer usage containing a specified graphic mode: char * far getModename; program: # include # include
#include
#include
int main (void) {/ * request autodetection * / int gdriver = DETECT, gmode, errorcode; int midx, midy, mode; char numname [80], modename [80]; / * initialize graphics and local variables * / initgraph ( & gdriver, & gmode, ""); / * read results = graphresult (); if (erroorcode! = grok) / * an error occurred * / {printf ("Graphics Error:% S / N", grapherrorMSG (ERRORCODE)); Printf ("Press Any Key to Halt:"); getCH (); exit (1); / * Terminate with an error code * /} midx = getmaxx () / 2; midy = getMaxy () / 2; / * Get mode number and name strings * / mode = getgraphmode (); sprintf (Numname, "% D is the current mode number.", Mode); sprintf (Modename, "% s is the current graphics mode." , getmodename (mode)); / * display the information * / settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (midx, midy, numname); outtextxy (midx, midy 2 * textheight ( "W"), modename); / * Clean up * / getch (); closegraph (); return 0;} Double Fabs (double x); return the absolute value of the double precision X. Void Far * Farcalloc (unsigned long NUnits, unsigned long unitsz); pile gives NUs from far nits elements, each element occupies a set of storage areas. Success is the pointer to the newly allocated memory block; if the storage space is not enough, return NULL. Unsigned long farcoreleft (void); Returns the size of the unused storage area in the far. Void Farfree (Void Far * Block); Releases the previously assigned memory blocks in the distinction. Void Far * Farmalloc (unsigned long nbytes); distributing the memory block of the NBYTES byte from the far pile, returns a new address. Void Far * FarRealloc (Void Far * Oldblock, unsigned long nbytes; adjusting the size of the assigned memory block is Nbytes. If necessary, copy the contents in the block to a new location. Note: All available RAMs can be assigned, a block greater than 64K can be assigned. Far pointer is used to access the assigned block. Returns the address of the reassigned memory block. Returning NULL if the storage block is reassigned.
Struct FCB {Char FCB_Drive; / * 0 = default, 1 = a, 2 = b * / char FCB_NAME [8]; / * file name * / char fcb_ext [3]; / * file extension * / short fcb_curblk; / * Current block number * / short fcb_recsize; / * Logical record size in bytes * / long fcb_filsize; / * File size in bytes * / short fcb_date; / * Date file was last written * / char fcb_resv [10]; / * Reserved for DOS * / CHAR FCB_CURREC; / * CURRENT RECORD IN Block * / long fcb_randem; / * random record number * /}; int fclose (file * stream); turn off a stream. Successful returns 0; failure is returned to EOF. Int fcloseall (Void); Turn off all open streams, except stdin, stdout, stdprn, stderr, and stdaux. Char * FCVT (Double Value, Int NDIG, INT * DEC, INT * SIGN); convert floating point numbers into strings, convert floating point value VALUE to NDIG's character string with empty characters, return to this character The string of the pointer, the position of the decimal point, is stored in the position of the DEC, and the DEC is indicated by the decimal point on the left side of the string returned. The returned string itself does not have a decimal point. If the value of the Value is negative, the value points to the value from SIGN nonback; otherwise it is zero. FILE * FDOPEN (INT Handle, Char * Type); Turn the stream to a file description word. FDOPEN makes the stream Stream with a file description word obtained from CREAT, DUP, DUP2 or OPEN. The type of flow must match the mode of the open file description word Handle. Type string Type can be one of the following values: R, open for read-only; W, create for writing; A, open it for writing, create when the file does not exist; R , open The existing file is used to update (read and write); A , add open, the file does not exist, and update it at the end. Returns a new open stream when successful. Returns NULL when an error is wrong. INT Feof (file * stream); Test the macro of the file tail mark for the STREAM. If the file tail mark EOF or Ctrl-z returns a non-zero value; otherwise, it returns 0. #include int ferror (file * stream); test the macro that is written to write errors. If the error on the given stream is detected, it returns a non-0 value. Struct ffblk {char ff_reserved [21]; char ff_attrib; unsigned ff_ftime; unsigned ff_fdate; long ff_fsize; char ff_name [13];}; int fflush (file * stream); clear the buffer of the input stream, so that it is still open, and Write the contents of the buffer of the output stream into the file it contacted. Returns 0 when successful, returns EOF when an error is wrong. INT FGETC (FILE * stream); reads the next character from the stream. Success is to return the next character in the input stream; return EOF to the file end or error.
INT FGETCHAR (VOID); When reading characters from standard input streams, it is defined as a macro of Getc (stdin). Returns the next character in the input stream stdin, which has been converted into a shaping value of unsigned extensions. Returns EOF when you encounter an error or file. INT FGETPOS (File Stream, FPOS_T * POS); get the current file pointer. FGETPOS holds the position of the file pointer connected to the Stream to the place referred to in POS. Where the type fpos_t is defined in stdio.h as a typeddf long fpos_t; returns 0 when successful; when it fails, it returns a non-0 value. Char * fgets (char * s, int N, file * stream); Read the N-1 character from the stream, or exchange the contents, stored in S, stored in S. Unlike gets, FGETs reserves the changing tabs in S unto. An empty byte is added to S for marking the end of the string. Returns the string fingered by S when successfully; returns NULL at an error or encounter files. Long FileLength; Returns the number of bytes of the file length of the handle, returns -1L when the error is wrong. INT fileno (file * stream); returns a file description word connected to the stream. INT fileno (file * stream); returns a file description word connected to the stream. enum fill_patterns {/ * Fill patterns for get / setfillstyle * / 0 EMPTY_FILL, / * fills area in background color * / 1 SOLID_FILL, / * fills area in solid fill color * / 2 LINE_FILL, / * --- fill * / 3 LTSLASH_FILL, / * /// Fill * / 4 Slash_Fill, / * /// Fill with thrill, / * /// Fill with thrill, / * /// Fill * / 7 HATCH_FILL, / * light hatch fill * / 8 XHATCH_FILL, / * heavy cross hatch fill * / 9 INTERLEAVE_FILL, / * interleaving line fill * / 10 WIDE_DOT_FILL, / * Widely spaced dot fill * / 11 CLOSE_DOT_FILL, / * Closely spaced dot fill * / 12 User_fill / * user defined Fill * / Void Far Fillellipse (int X, int y, int xradius, int yradius); draw a filled ellipse. Centered by (x, y), XRADIUS and YRADIUS are horizontal and vertical half-axis, with the current color drawing edge, draw an ellipse, fill with the current fill color and filling. INT FindFirst (const char * pathname, struct ffblk * ffblk, int attrib); Search Disk Directory. Start searching for 0x4e via DOS system to search for disk directories. The panel path file name you are looking for in Pathname is included. The file name can contain wildcards (such as * or?). If a matching file is found, fill the file directory information into the FFBLK structure. Attrib is the file attribute bytes of MS-DOS, which is used to select files in the search process.
Attrib is one of the following values defined in dos.h: fa_rdonly, read-only; FA_HIDDEN hide; FA_SYSTEM system file; FA_Label volume label; fa_Direc, directory; fa_arch, file. can be referred to>. Structure FFBLK format is as follows : struct ffblk {char ff_reserved [21}; / * Reserved by DOS * / char ff_attrib; / * Property Find * / INT FF_FTIME; / * File Time * / INT F_FDATE; / * File Date * / long ff_fsize; / * file Size * / char ff_name [13}; / * File name * / After successfully found the file name matched with the search path Pathname; otherwise returns -1. INT FINDNEXT (Xtruct Ffblk * Ffblk); Continue to press FindFirst's PathName search disk directory. Successfully found subsequent file names that matches the search path Pathname back to 0; otherwise returns -1. Void Floodfill (int X, int y, int border); pops a bounded area. Double Floor (double X); returns the maximum integer represented by <= x with double precision floating point. INT flushall (void); Clear all buffers. Clear all buffers associated with the input stream, write all the contents of all buffers connected to the output stream to the respective files, follow the read operations behind Flushall, read new data from the input file to In the buffer. Returns an integer representing the total number of input streams and output streams. Couvel FMOD (double x, double y); returns the x to Y size, that is, the remainder of X / Y. Void fnmerge (CHAR * PATH, Const Char * Drive, Const Char * DIR, Const Char * Name, Const Char * EXT), established a PATH in components such as a given panel path file name extension. If DRIVE gives X:, DIR gives / dir / subdir /, name gives Name, and .ext gives .ext, according to a given component, a complete panel path file name PATH is: X : /Dir/cubdir/name.ext int fnsplit (const char * path, char * drive, char * CIR, Char * name, char * ext); Decompose the panel path file name extension given by PATH Each component. Return to an integer. FILE * FOPEN (const char * filemane, const char * mode); Open file filemane returns the stream of contact; error Returns NULL. The values of the Mode string include: r, open for reading; W, open for writing; A, open for writing after the original content; R , open existing files for update (read and write); W creation new file is used to update; A , open it for updates after the original content, if the file does not exist. Unsigned fp_off (Void Far * Farptr); Returns the address offset of far pointer Farptr. Int fprintf (file * stream, const char * format [, argument, ...]); as the content of the original copy format string Format is in the streaming stream, each time a%, according to the specified format, sequentially output an expression in turn The value of the formula Argument is in the stream stream, returns the number of characters written. Returns EOF when an error is wrong.
File * stream; void main (void) {long L; float fp; char S [81]; char C; stream = fopen ("fscanf.txt", "w "); if (stream == null) Printf (" The file fscanf.out was not opened / n "); Else {FPRINTF (stream,"% s% ld% f% c "," a-string ", 65000, 3.14159, 'x'); / * set Pointer To Beginning of file: * / fseek (stream, 0l, seek_set); / * read data back from file: * / fscanf (stream, "% s", s); fscanf (stream, "% ld", & l); fscanf (stream, "% f", fscanf (stream, "% c", & c); / * Output data read: * / printf ("% s / n", s); Printf ("% ld / n", L PRINTF ("% f / n", fp); Printf ("% c / n", c); fclose (stream);}} int FPUTC (int C, file * stream); write a character to the stream Returns EOF. INT FPUTCHAR (INT C) when successfully returned, fails or error, sending a character to the screen. Equivalent to FPUTC (C, Stdout); returns the word, failure or error Returns EOF. INT FPUTS (Const Char * S, File * Stream); send S-I-empty character string to the stream in the stream, do not change the line character '/ n', not copy string end value '/ 0 '. Returns the last character when successfully, returns EOF. Size_T FREAD (Void * PTR, SIZE_T SIZE, SIZE_T N, FILE * STREAM); N items read from the input stream stream, each The length of the item is a size byte, in the block referred to by the PTR. Returns the number of data items (not bytes) (not the number of bytes) when successful; 5. Void Free (V Oid * block); Release the previously assigned first address of the Block block. INT FreeMem (unsigned segx); Releases the memory block previously assigned by Allocmem as Segx. FILE * FREOPEN (const char * filename, const char * model, file * stream); instead of the file specified by the open stream Stream with files specified by FileName. Returns stream and returns NULL when an error is wrong. Double frexp (double x int * exponent); decomposes X into an intent index. The given double-precision number X is decomposed into an index n between 0.5 and 1 mutual M and an integer, so that the original x = m * (2 of 2), deposit the shaping index N into the address referred to in Exponent. In the middle, return the tail number m.
INT fscan (file * stream, char * format, address, ...); fscanf scanning input field, read from streaming stream, each read a field, follow the format string referred to by Format String from% The start format is formatted after depositing the corresponding address Address. Returns the number of successfully scan, converts, and stores the input field, and returns EOF in the end of the file. File * stream; void main (void) {long L; float fp; char S [81]; char C; stream = fopen ("fscanf.txt", "w "); if (stream == null) Printf (" The file fscanf.out was not opened / n "); Else {FPRINTF (stream,"% s% ld% f% c "," a-string ", 65000, 3.14159, 'x'); / * set Pointer To Beginning of file: * / fseek (stream, 0l, seek_set); / * read data back from file: * / fscanf (stream, "% s", s); fscanf (stream, "% ld", & l); fscanf (stream, "% f", fscanf (stream, "% c", & c); / * Output data read: * / printf ("% s / n", s); Printf ("% ld / n", L PRINTF ("% f / n", fp); Printf ("% c / n", c); fclose (stream);}} int FSeek (file * stream, long offset, int because Repositioning the location of the file structure. FSeek Sets the file pointer to the stream STREAM to the new location, the distance of the new location and the location of the file location is OFFSET byte .Whence value must be 0, 1 or 2 One, representing three symbol constants defined in stdio.h: 0 is the seek_set, which is the file start position; 1 is seek_cur, is the current pointer position; 2, seek_end, is the end of the file. After calling FSeek, In the updated file location, the next operation can be input; it can also be an output. When the pointer is successfully moved, FSEEK returns 0; an error or a non-0 value is returned.