C language function library

xiaoxiao2021-03-06  84

Function Daquan (A starting)

Function Name: Abort Features: Actual Termination One Process Usage: Void Abort (Void); Procedure: #include #include

INT main (void) {Printf ("Calling Abort () / n"); Abort (); Return 0; / * this is never reached * /}

Function Name: ABS Function: Absolute Usage of Integer: Int ABS (INT I); Procedure: #include #include

INT main (void) {int number = -1234;

Printf ("Number:% D Absolute Value:% D / N", Number, ABS (Number); Return 0;}

Function Name: Absread, Abswirte Fence: Absolute Disk Sector Read, Write Data Usage: Int Absread (Int Drive, Int Nsects, Int Sectno, Void * Buffer);

Int Abswrite (int DRIVE, INT NSECTS, IN TsectNo, Void * Buffer); program case: / * AbsRead Example * /

#include #include #include #include

INT main (void) {Int i, start, ch_out, sector; char buf [512];

Printf ("INSERT A Diskette Into Drive A and Press Any Key / N"); getch (); sector = 0; if (Absread (0, 1, Sector, & Buf)! = 0) {Perror ("Disk Problem") (1);} Printf ("read ok / n"); start = 3; for (i = 0; i <80; i ) {ch_out = buf [strint i]; PUTCHAR (ch_out);} printf ("/ n"); return (0);

Function Name: Access Features: Determines the access to the file: int access (const char * filename, int us); program: #include #include

INT file_exists (char * filename);

INT main (void) {Printf ("Does Notexist.fil EXIST:% S / N", File_exists ("NOTEXISTS.FIL")? "YES": "no"); return 0;}

INT file_exists (char * filename) {return (access (filename, 0) == 0);}

Function Name: ACOS Features: Anti-String Function Usage: Double ACOS (Double X); Procedure: #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 storage segment: int Allocmem (unsigned size, Unsigned * seg); program example: #include #include #include

INT main (void) {unsigned int size, segp; int stat;

Size = 64; / * (64 x 16) = 1024 BYTES * /

Stat = allocmem (size, & segp); if (stat == -1) Printf ("Allocated Memory At Segment:% x / n", segp); Else Printf ("Failed: Maximum Number of Paragraphs Available IS% U / N "

STAT);

Return 0;}

Function Name: Arc Features: Draw an Arc Usage: Void Far Arc (int X, int y, int stangle, int endangle, int RADIUS);

Delivatives: #include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, errorcode; int midx, midy; int stand = 45, endangle = 135; int RADIUS = 100;

/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");

/ * read results = graphresult (); / * an error occurred * / if (erroorcode! = grok) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH ();

EXIT (1); / * Terminate with an error code * /}

MIDX = getmaxx () / 2; Midy = getMaxy () / 2; setColor (GetMaxColor ());

/ * DRAW ARC * / ARC (MIDX, MIDY, STANGLE, Endangle, RADIUS);

/ * CLOAN UP * / GETCH (); closegraph (); return 0;}

Function Name: AscTime function: conversion date and time is ASCII code usage: char * asctime (const struct tm * tblock); program: #include #include #include

INT main (void) {structureTM T; char STR [80];

/ * SAMPLE Loading of TM Structure * / T.TM_SEC = 1; / * seconds * / t.tm_min = 30; / * minutes * / t.tm_Hour = 9; / * Hour * / 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 assetime * / t.tm_isdst = 0; / * is daylight savtime; does not show in assetime * /

/ * Converts structure to null terminated

String * /

STRCPY (STR, ASCTIME (& T)); Printf ("% s / n", STR);

Return 0;}

Function Name: Asin Features: Anti-String Function Usage: Double Asin (Double X); Procedure: #include #include

INT main (void) {double result; double x = 0.5;

Result = asin (x); Printf ("The Arc sin of% LF IS% LF / N", X, Result); Return (0);}

Function name: Assert function: Test a condition and may make the program termination method: void assert (int test); program: #include #include

#include

Struct itemograph {int key; int value;};

/ * Add item to list, make sure list is not null * / void additem (struct item * itemptr) {

Assert (itemptr! = null); / * Add item to list * /}

INT main (void) {additem (null); return 0;}

Function Name: ATAN Fenergy: Anti-orthogonics: Double Atan (Double X); Procedure: #include #include

INT main (void) {double result; double x = 0.5;

Result = Atan (x); Printf ("THE Arc Tangent Of% LF IS% LF / N", X, Result; Return (0);}

Function Name: Atan2 Function: Calculate Y / X Urgent Crystal Usage: Double Atan2 (Double Y, Double X); Procedure: #include #include

INT main (void) {double result; double x = 90.0, y = 45.0;

Result = Atan2 (Y, X); Printf ("The Arc Tangent Ratio of% LF IS% LF / N", (Y / X), Result;

Return 0;}

Function Name: Atexit Function: Register Termination Function Usage: Int Atexit (Atexit_t Func); Project: #include #include void exit_fn1 (void) {printf ("EXIT Function # 1 Called / n ");

Void exit_fn2 (void) {printf ("exit function # 2 called / n");}

INT main (void) {/ * post exit function # 1 * / atexit (exit_fn1); / * post exit function # 2 * / atexit (exit_fn2); return 0;}

Function Name: ATOF function: Convert strings into floating point measures: 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 strings to growth integer: int Atoi (const char * nptr); program case: #include #include

INT main (void) {Int n; char * str = "12345.67";

n = ATOI (STR); Printf ("String =% S INTEGER =% D / N", STR, N); RETURN 0;}

Function Name: ATOL function: Conversion of string to growth integer: long atol (const char * nptr);

#include #include

INT main (void) {long L; char * str = "98765432";

L = atol (LSTR); Printf ("String =% S INTEGER =% LD / N", STR, L); RETURN (0);}

C language function library

Function Daquan (B)

Function name: bar

Function: Draw a two-dimensional bar graph usage: Void Far Bar (int LEFT, INT TOP, INT RIGHT, INT BOTTOM);

#include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int midx, midy, i;

/ * 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;

/ * loop through the fill pattern * / for (i = solid_fill; ibr> {/ * set the Fill Style * / setfillstyle (i, getmaxcolor ());

/ * DRAW THE BAR * / BAR (MIDX-50, MIDY-50, MIDX 50, MIDY 50);

Getch ();

/ * Clean up * / closegraph (); return 0;}

Function Name: BAR3D function: draw a three-dimensional bar3d (int LEFT, INT TOP, INT Right, INT BOTTOM, INT DEPTH, INT TOPFLAG);

#include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int midx, midy, i;

/ * Initialize Graphics, Local Variables * / Initgraph (& gdriver, & gmode, "");

/ * read results = graphresult (); if (error (error) / * an error opcurred * / {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); / * terminate with error code * /}

MIDX = getmaxx () / 2; Midy = getMaxy () / 2;

/ * loop through the fill pattern * / for (i = Empty_Fill; IBR> {/ * set the Fill Style * / setFillStyle (i, getmaxcolor ());

/ * DRAW THE 3-D BAR * / BAR3D (MIDX-50, MIDY-50, MIDX 50, MIDY 50, 10, 1);

Getch ();

/ * Clean up * / closegraph (); return 0;}

Function name: BDOS function: DOS system call

Usage: int 5, unsigned dosdx, unsigned dosal; example:

#include #include

/ * GET CURRENT Drive as a, b, ... * / char current_drive (void) {char curdrive;

/ * Get Current Disk as 0, 1, ... * / curdrive = BDOS (0x19, 0, 0); Return (A Curdrive);

Int main (void) {Printf ("THE CURRENT DRIVE IS% C: / N", current_drive ()); return 0;}

Function Name: BDOSPTR Function: DOS System Call Usage: Int Bdosptr (INT DOSFUN, VOID * Argument, Unsigned Dosal);

#include #include #include #include #include #include

#define buflen 80

INT 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, Buffle); Printf ("The Current Directory IS:% S / N", BUFFER);

Return 0;}

Function Name: BIOSCOM Features: Serial I / O Communication Usage: Int Bioscom (int CMD, CHAR ABYTE, INT Port);

#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); cprintf ("... 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 ()) {IF ((in = getCH ()) == / x1b) DONE = True; bioscom (1, in, com1);}} Return 0;

Function Name: BiosDisk Features: Software Drive I / O Usage: Int BiosDisk (int CMD, Int Drive, Int Head, Int Track, INT Se

Int nsects, void * buffer;

#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, Buff); Result & = 0x02; (Printf ("Drive A: Ready / N"): (Printf ("Drive A: NOT Ready / 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, Buff); Result & = 0x02; (Printf ("Drive A: Ready / N"): (Printf ("Drive A: NOT Ready / N "))));

Return 0;}

Function Name: BIOSKEY function: Directly use the keyboard interface usage of the BIOS service: int BIOSKEY (INT CMD);

#include #include #include

#define right 0x01 #define left 0x02 #define ctrl 0x04 #define alt 0x08

INT main (void) {int key, modifier

/ * Function 1 Returns 0 Until a key ispessed * / while (bioskey (1) == 0);

/ * Function 0 returns the key "is waiting * / key = bioskey (0);

/ * USE Function 2 To Dermine if Shift Keys WERE Used * / Modifiers = Bioskey (2); if (Modifiers) {Printf ("["); IF (Modifiers & Right) 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 Features: Returns the Save Block Size: Int BiosMemory (Void);

#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: Directly use the printer I / O using BIOS service : INT BiospRINT (int CMD, INT BYTE, INT Port);

#include #include #include

Int main (void) {#define status 2 / * printer status command * / #define portnum 0 / * Port Number for lpt1 * /

Int status, Abyte = 0;

Printf ("" ",", ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ); if (status & 0x08) Printf ("I / O Error./N");

IF (Status & 0x10) Printf ("SELECTED./N"); if (status & 0x20) Printf ("Out of Paper./N");

IF (status & 0x40) Printf ("Acknowledge./N"); if (status & 0x80) Printf ("not busy./n");

Return 0;}

Function Name: Biostime Features: Read or set BIOS Time: Long Biostime (int CMD, long newtime);

#include #include #include #include

INT main (void) {long bios_time;

CLRSCR (); CPRINTF ("THE NUMBER OF Clock Ticks Since Midnight IS: / R / N"); CPrintf ("The Number of Seconds Since Midnight IS: / R / N"); CPrintf ("The Number of Minutes Since Midnight IS: / r / n "); CPRINTF (" THE NUMBER OF Hours Since Midnight IS: / R / N "); CPrintf (" / R / NPRESS ANY Key To Quit: "); While (! kbhit ()) { BIOS_TIME = Biostime (0, 0L);

gotoxy (50, 1); CPRINTF ("% lu", bios_time);

gotoxy (50, 2); CPrintf ("%. 4F", BIOS_TIME / CLK_TCK);

gotoxy (50, 3); CPrintf ("%. 4F", BIOS_TIME / CLK_TCK / 60);

Gotoxy (50, 4); CPRINTF ("%. 4F", BIOS_TIME / CLK_TCK / 3600);} return 0;} function name: brk function: change data segment space allocation method: int BRK (Void * endds); :

#include #include

INT main (void) {char * ptr;

Printf ("Changing Allocation with BRK () / N");

PTR = malloc (1); Printf ("Before BRK () Call:% Lu Bytes Free / N", Coreleft ()); BRK (PTR 1000); Printf ("After BRK () Call:% Lu Bytes Free / N ", Coreleft ()); Return 0;}

Function Name: BSearch Features: Two-Binary Search: Void * BSearch (const void * key, const void * base, size_t * NELEM,

Size_t width, int (* fcmp) (const void *, const *));

#include #include

#define NELEMS (Arr) (Sizeof (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 (*) (const void *, const void *)) Is Needed to Avoid A Type Mismatch Error At Compile 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"); Else Printf ("512 ISN T ITE TABLE./N");

Return 0;}

C language function library

Function Daquan (beginning)

Function name: CABS function: calculation of absolute value usage: Double Cabs (Struct Complex Z);

#include #include

INT main (void) {struct complex z; Double Val;

Z.x = 2.0; z.y = 1.0; VAL = CABS (z);

Printf ("The Absolute Value of% .2LFI% .2LFJ IS% .2LF", Z.X, Z.Y, VAL); RETURN 0;}

Function Name: Calloc function: Assign Main memory usage: void * calloc (size_t nlem, size_t elsize);

#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: rounded rounding: Double CEIL (Double X);

#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 reading string usage: char * cgets (char * STR); program case:

#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 ("getCurDir ()"); exit (1);} Printf ("current directory is: //% s / n", OLD_DIR); if (chDIR ("//")) {PERROR ("chdir ()"); exit (1);}

IF (GetCurdir ("" 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 usage: 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 T Make% s Read-Only / N", FileName); Else Printf ("MADE% s Read-Only / N", FileName);}

Function Name: Chsize Features: Change File Size Usage: Int Chsize (INT HANDLE, Long Size);

#include #include #include

INT main (void) {Int Handle; char buf [11] = "0123456789";

/ * CREATE TEXT FILE Containing 10 Bytes * / Handle = Open ("Dummy.fil", O_Creat); Write (Handle, BUF, Strlen (BUF));

/ * Truncate the file to 5 bytes in size * / chsize (handle, 5);

/ * Close the file * / close (Handle); Return 0;

Function Name: CIRCLE function: at a given radius (x, y) as a circular circle: Void Far Circle (int X, int y, int RADIUS);

#include #include #include #include

int main (void) {/ * request auto detection * / int gdriver = DETECT, gmode, errorcode; int midx, midy; int radius = 100; / * initialize graphics and local variables * / initgraph (& gdriver, & gmode, "") ;

/ * read results = graphresult (); if (error (error) / * an error opcurred * / {printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf (" Press any key to halt: "); getCH (); exit (1); / * Terminate with an error code * /}

MIDX = getmaxx () / 2; Midy = getMaxy () / 2; setColor (GetMaxColor ());

/ * Draw the circle * / circle (MIDX, Midy, Radius);

/ * CLOAN UP * / GETCH (); closegraph (); return 0;}

Function Name: ClearDevice Features: Clear Graphics Screen Usage: Void Far ClearDevice (Void);

#include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int midx, midy

/ * 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; setColor (GetMaxColor ());

/ * for centering screen messageity * / setxtjustify (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 * / cleanvice ();

/ * Output Another Message * / Outtextxy (Midx, Midy, "Press any key to quit:"); / * clean up * / getch (); closegraph (); return 0;}

Function Name: ClearerR Function: Reset Error Sign Usage: Void Clearerr (File * Stream);

#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 (FERROR (FP)) {/ * DISPLAY An Error Message * / Printf ("Error Reading from Dummy.fil / N);

/ * RESET the error and EOF INDCATORS * /

Clearerr (fp);

Fclose (fp); Return 0;

Function Name: ClearViewPort Features: Clear Graphic View Law: Void Far ClearViewPort (VOID);

#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 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 * /}

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 * / cleanviewPort ();

/ * Output Another Message * / Outtextxy (0, 0, "Press Any Key To Quit:");

/ * CLOAN UP * / GETCH (); closegraph (); return 0;}

Function Name: _Close, Close Features: Close File Handle Usage: Int Close (INT Handle);

#include #include #include #include

Main () {Int Handle; Char BUF [11] = "0123456789";

/ * CREATE A FILE Containing 10 bytes * /

Handle = Open ("new.fil", o_creat); if (Handle> -1) {Write (Handle, BUF, Strlen (BUF));

/ * Close the file * / close (Handle);} else {printf ("error opening file / n");} return 0;}

Function Name: Clock function: Determine processor time usage: Clock_t clock (void);

#include #include #include

Int main (void) {clock_t start, end; start = clock ();

DELAY (2000);

End = clock (); Printf ("Time Was:% f / n", (end - start) / clk_tck;

Return 0;}

Function Name: Closegraph Function: Turn off Graphics System Us: Void Far Closegraph (Void);

#include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int x, y;

/ * 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); / * 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 of the line: Void Clreol (Void);

#include

Int main (void)

{CLRSCR (); CPRINTF ("The Function Clreol Clears All Characters from THE / R / N"); CPRINTF ("Cursor Position To The End of The Line with I / R / N"); CPrintf ("Current Text Window, WITHOUT MOVING THE CURSOR./R/N "); CPRINTF (" Press any key to contact... "); gotoxy (14, 4); getCh ();

CLREOL (); getCH ();

Return 0;}

Function Name: CLRSCR Function: Clear text mode window usage: Void ClrsCr (void);

#include

INT main (void) {INT I;

CLRSCR (); for (i = 0; I <20; I ) CPRINTF ("% D / R / N", I); CPRINTF ("/ R / NPRESS ANY Key to Clear 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);

#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);

#include #include int main (void) {Double Result; double x = 0.5;

Result = COS (X); Printf ("THE COSINE OF% LF IS% LF / N", X, Result); Return 0;}

Function Name: COSH Function: Double Cosine Function Usage: Dluble Cosh (Double X);

#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 Features: Returns information about the country: Struct Country * Country (int COUNTRYCODE, STRUCT country * country);

Example:

#include #include

#define usa 0

INT main (void) {struct country country_info;

Country (USA, & Country_INFO); Printf ("THE Currency Symbol for the USA IS:% S / N", Country_info.co_curr;

Return 0;}

Function Name: CPRINTF function: send formatted output to screen usage: int CPRINTF (const char * format [, argument, ...]);

#include

INT main (void) {/ * clear the screen * / clrs ();

/ * CREATE A TEXT WINDOW * / WINDOW (10, 10, 80, 25);

/ * Output Some text in the window * / cprintf ("Hello WORLD / R / N");

/ * WAIT for a key * / getch (); return 0;}

Function name: CPUTS function: write characters to screen usage: void cputs (const char * string);

#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 forning 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);

#include #include #include #include

INT main (void) {Int Handle; char buf [11] = "0123456789";

/ * Change the default file mode from text to binary * / _fmode = o_binary; / * create a binary file forreading and write * / handle = Creat ("Dummy.fil", S_IREAD | S_IWRITE);

/ * Write 10 bytes to the file * / write (Handle, BUF, Strlen (BUF))

/ * Close the file * / close (Handle); Return 0;

Function Name: CreatNew Function: Create a New File: Int Creatnew (const char * filename, int attrib);

#include #include #include #include #include

INT main (void) {Int Handle; char buf [11] = "0123456789";

/ * Attempt to create a file what doesn t already exist * / handle = CreatNew ("Dummy.fil", 0);

IF (Handle == -1) Printf ("Dummy.fil Already Exists./N"); Else {Printf ("Dummy.fil Success Created./N"); Write (Handle, BUF, Strlen (BUF)); Close (Handle);} return 0;

Function Name: CreatTemp Fenergy: Create a new file or rewrite an existing file usage: int CreatTemp (const char * filename, int attrib);

#include #include #include

INT main (void) {int Handle; char Pathname [128];

STRCPY (Pathname, "//");

/ * CREATE a unique file in the root directory * / handle = creattemp (pathname, 0);

Printf ("% s was the unique file created./n", pathname); Close (Handle); Return 0;}

Function Name: CSCANF function: Format input from the console: int Cscanf (char * format [, argument, ...]);

#include

INT main (void) {char string [80];

/ * CLEAR THE screen * / clrs ();

/ * Prompt the user for input * / cprintf ("Enter A String With no spaces:");

/ * read the input * / cscanf ("% s", string);

/ * Display What was read * / CPrintf ("/ R / NThe String Entered IS:% S", String); Return 0;}

Function name: CTIME function: convert date and time to string usage: char * ctime (const time_t * time); program case: #include #include

INT main (void) {TIME_T T;

Time (& T); Printf ("Today S Date:% S / N", CTIME (& T)); Return 0;}

Function Name: Ctrlbrk Features: Sets Ctrl-Break Processor Usage: Void CtrlBrk (* FPTR) (Void);

#include #include

#define abort 0

INT C_BREAK (VOID)

{Printf ("Control-Break Pressed. Program Aborting ... / N"); return (abort);}

INT main (void) {ctrlbrk (c_break); for (;;) {Printf ("looping ... press to quit: / n");} return 0;}

C language function library

Function Daquan (D start)

Function Name: DELAY Energy: Pause the execution of the program for a period of time (milliseconds): void delay (unsigned milliseconds); example: / * Emits a 440-hz Tone for 500 MilliseConds * / #include

INT main (void) {Sound (440); DELAY (500); noid ();

Return 0;}

Function Name: Delline Features: Remove a line of use in the text window: Void Delline (Void);

#include

INT main (void) {clrs CL (); CPrintf ("THE FUNCTION DELLETES / THE LINE Containing THE / R / N"); CPRINTF ("" Cursor and Moves All Lines / Below It One Line Up./R/N ") CPrintf ("Delline Operates forin The / Currently Active Text / R / N"); CPrintf ("Window. Press any key to / continue..."); gotoxy (1, 2); / * Move the cursor to the the Second Line and first column * / getch ();

Delline (); getCH ();

Return 0;}

Function Name: DetectGraph Function: Determines Graphics Drivers and Mode Law by Detection: Void Far DetectGraph (Int Far * GraphDriver, Int Far * graphmode);

#include #include #include #include

/ * name of the various cards supported * / char * DNAME [] = {"Requests Detection", "A CGA", "AN MCGA", "AN EGA", "A 64K EGA", "A Monochrome EGA", " AN IBM 8514, "A Hercules Monochrome", "AT & T 6300 PC", "A VGA", "AN IBM 3270 PC"}; int main (void) {/ * returns detected hardware info. * / INT GDRIVER, GMODE , ERRORCODE;

/ * Detect graphics hardware available * / detectgraph (& gdriver, & gmode);

/ * Read Result of detectgraph call * / errorcode = graphresult (); if (ErrorCode! = GROK) / * An error ire {printf ("Graphics Error:% S / N", / GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); getCh (); exit (1); / * terminate with an error code * /}

/ * display the information detected * / clrs (); Printf ("You Have% S Video Display / Card./N", DNAME [GDRIVER]); Printf ("Press Any Key to Halt:"); getCH (); Return 0;}

Function Name: DIFFTIME function: calculate time difference between two moments: Double DiffTime (Time_t Time2, Time_t Time1);

#include #include #include #include

Int main (void) {TIME_T FIRST, SECOND

CLRSCR (); first = time (null); / * gets system time * / delay (2000); / * Waits 2 secs * / second = time (null); / * Gets system time again * /

Printf ("THE DIFCERENCE IS:% F / Seconds / N", DiffTime (Second, First)); getCH ();

Return 0;}

Function Name: Disable Features: Shield Interrupt Usage: Void Disable (Void);

/ *** Note: this is an interrupt service routine. You cannot Compile This Program with test stack overflow turned on and get an executable file what operates correctly. * /

#include #include #include

#define INTR 0X1C / * The Clock Tick Interrupt * / Void Interrupt (* OldHandler) (Void);

INT count = 0;

void interrupt handler (void) {/ * disable interrupts during the handling of the interrupt * / disable (); / * increase the global counter * / count ; / * reenable interrupts at the end of the handler * / enable (); / * Call the old routine * / oldhandler ();

Int main (void) {/ * save the old interrupt vector * / oldhandler = getVect (INTR);

/ * Install The New Interrupt Handler * / setVect (Intr, Handler);

/ * loop untric the counter Exceeds 20 * / while (count <20) Printf ("count IS% d / n", count);

/ * RESET The Old Interrupt Handler * / setVect (INTR, OLDHANDLER);

Return 0;}

Function Name: DIV function: Erase two integers, return business and expensive usage: DIV_T (int Number, int Denom);

#include #include

DIV_T X;

INT main (void) {x = div (10, 3); Printf ("10 Div 3 =% D Remainder D / N", X.quot, X.Rem);

Return 0;}

Function Name: DOSEXTERR Function: Get Extension DOS Error Information: Int DosexTerr (Struct Doserr * DBLKP);

#include #include

INT main (void) {file * fp; struct doserror info;

FP = FOPEN ("PERROR.DAT", "R"); if (! fp) PERROR ("Unable to open file forreading"; dosexterr (& info);

Printf ("Extended DOS Error / Information: / N"); Printf ("Extended Error: /% D / N", Info.exTerror); Printf ("Class: /% X / N", Info.class; Printf ("ACTION: /% x / n", info.action; Printf ("Error Locus: /% x / n", Info.locus;

Return 0;}

Function Name: Dostounix Features: Conversion Date and Time for UNIX Time Format: Long Dostounix (Struct Date * Dateptr, Struct Time * TimePtr);

#include #include #include #include

INT main (void) {time_t t; struct time d_time; struct date d_date; structTm * local; getdate (& D_DATE); GetTime (& D_TIME);

T = dostounix (& D_Date, & D_TIME); local = localtime (& T); Printf ("Time and Date: S / N", / asctime (local));

Return 0;}

Function Name: DrawPoly Features: Draw Polygon Usage: Void Far DrawPoly (Int Numpoints, Int Far * Polypoints);

#include #include #include #include

INT main (void) {/ * request auto detection * / int gDriver = detect, gmode, erroorcode; int maxx, maxy;

/ * OUR POLYGON ARRAY * / INT POLY [10];

/ * Initialize Graphics and local variables * / initgraph (& gdriver, & gmode, "");

/ * read results = graphResult (); if (errorcode! = grok) / * an error ocurred * / {printf ("graphics error:% s / n", / grapherrormsg (errorcode)); Printf "Press Any Key to Halt:"); getch (); / * Terminate with an error code * / exit (1);

Maxx = getmaxx (); maxy = getMaxy ();

POLY [0] = 20; / * 1st Vertext * / Poly [1] = MAXY / 2;

Poly [2] = Maxx - 20; / * 2nd * / poly [3] = 20;

Poly [4] = Maxx - 50; / * 3rd * / poly [5] = MAXY - 20;

Poly [6] = maxx / 2; / * 4th * / poly [7] = maxy / 2; / * DrawPoly Doesn T Automatically Close the Polygon, So We Close It. * / Poly [8] = Poly [0]; Poly [9] = poly [1];

/ * Draw the polygon * / drawpoly (5, poly);

/ * CLOAN UP * / GETCH (); closegraph (); return 0;}

Function name: DUP function: copy a file handle usage: int dup (int Handle);

#include #include #include #include

Void Flush (file * stream);

INT main (void) {file * fp; char msg [] = "this is a test";

/ * CREATE A file * / fp = fopen ("Dummy.fil", "W"); / * Write Some Data To The File * / FWRITE (MSG, Strlen (MSG), 1, FP);

CLRSCR (); Printf ("Press any key to flush / dummy.fil:"); getCH ();

/ * Flush the data to dummy.fil without closing it * / flush (fp);

Printf ("/ Nfile Was flushed, Press any / key to quit:"); getCh (); return 0;}

Void Flush (file * stream) {int duphandle;

/ * Flush TC s INTERNAL BUFFER * / FFLUSH (stream);

/ * Make a duplicate file hand is * / duphandle = DUP (Fileno (stream));

/ * Close The duplicate handle to flush the dos buffer * / close (duphandle);

Function Name: DUP2 Function: Copy File Handle Usage: Int Dup2 (INT OLDHANDLE, INT NewHandle);

#include #include #include #include

Int main (void) {#define stdout 1

INT NUL, OLDSTDOUT; Char Msg [] = "this is a test";

/ * CREATE A file * / NUL = Open ("Dummy.fil", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);

/ * Create a duplicate handle for standard output * / oldstdout = dup (STDOUT); / * redirect standard output to DUMMY.FIL by duplicating the file handle onto the file handle for standard output * / dup2 (nul, STDOUT).;

/ * Close The Handle for Dummy.fil * / Close (NUL);

/ * Will Be Redirected Into Dummy.fil * / Write (stdout, msg, strlen (msg));

/ * RESTORE Original Standard Output Handle * / DUP2 (OldStdout, Stdout);

/ * Close Duplicate Handle for Stdout * / Close (OldStdout);

Return 0;}

Function Daquan (E starting)

Function name: ECVT

Function: Convert a floating point number to a string

Usage: Char ECVT (Double Value, Int Ndigit, INT * DECPT, INT * SIGN);

Example:

#include

#include

#include

Int main (void)

{

CHAR * STRING;

Double Value;

INT DEC, SIGN;

INT ndig = 10;

CLRSCR ();

Value = 9.876;

String = ECVT (Value, NDIG, & DEC, & SIGN);

Printf ("String =% s DEC =% D /

SIGN =% D / N ", String, DEC, SIGN;

VALUE = -123.45;

NDIG = 15;

String = ECVT (Value, NDIG, & DEC, & SIGN);

Printf ("String =% s DEC =% D Sign =% D / N",

String, DEC, SIGN;

Value = 0.6789E5; / * scientific

NOTATION * /

NDIG = 5;

String = ECVT (Value, NDIG, & DEC, & SIGN);

Printf ("String =% s DEC =% D /

SIGN =% D / N ", String, DEC, SIGN;

Return 0;

}

Function name: Ellipse

Function: draw an ellipse

Usage: Void Far Ellipse (int X, int y, int stangle, int endangle,

INT XRADIUS, INT YRADIUS;

Example:

#include

#include

#include

#include

Int main (void)

{

/ * Request Auto Detection * /

INT GDRIVER = Detect, Gmode, ERRORCODE

Int midx, midy;

INT Stangle = 0, endangle = 360;

INT XRADIUS = 100, Yradius = 50;

/ * Initialize Graphics, Local Variables * /

INITGRAPH (& GDriver, & gmode, ");

/ * Read Result of Initization * /

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 * /

Ellipse (MIDX, Midy, Stangle, Endangle,

XRADIUS, YRADIUS;

/ * Clean Up * /

Getch ();

Closegraph ();

Return 0;

}

Function name: enable

Function: open hardware interruption

Usage: void enable (void);

Example:

/ * ** 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 Willoperate Correctly.

* /

#include

#include

#include

/ * The clock tick interface interrupt * /

#define INTR 0x1C

Void Interrupt (* OldHandler) (Void);

INT count = 0;

Void Interrupt Handler (Void)

{

/ *

Disable Interrupts During The Handling of The Interrupt

* /

disable ();

/ * Increase the global counter * /

COUNT ;

/ *

RE ENABLE Interrupts at the end of the handler

* /

ENABLE ();

/ * Call the Old Routine * /

OldHandler ();

}

Int main (void)

{

/ * save the old interrupt vector * /

OldHandler = GetVect (INTR);

/ * Install the new interface interrupt 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);

Example:

#include

#include

#include

#include

#include

Int main (void)

{

INT HANDLE;

Char msg [] = "this is a test";

CHAR CH;

/ * CREATE A file * /

Handle = Open ("Dummy.fil",

O_CREAT | O_RDWR,

S_iread | s_iwrite;

/ * Write Some Data to the file * /

Write (Handle, MSG, Strlen (MSG));

/ * Seek to the beginning of the file * /

Lseek (Handle, 0L, Seek_set);

/ *

Reads Chars from The File Until Hit Eof

* /

DO

{

Read (Handle, & Ch, 1);

Printf ("% C", CH);

} while (! EOF (Handle));

Close (Handle);

Return 0;

}

Function name: EXEC ...

Function: Load and run other programs

Usage: int execl (char * pathname, char * arg0, arg1, ..., argn, null);

Int Execle (Char * Pathname, Char * Arg0, Arg1, ..., Argn, ​​NULL,

Char * envp []; int execlp (char * pathname, char * arg0, arg1, .., null);

INT EXECPLE (Char * Pathname, Char * Arg0, Arg1, ..., NULL,

Char * envp []);

Int Execv (Char * Pathname, Char * Argv []);

int execve (char * pathname, char * argv [], char * envp []);

Int Execvp (Char * Pathname, Char * Argv [];

Int Execvpe (Char * Pathname, Char * Argv [], char * envp []);

Example:

/ * EXECV EXAMPLE * /

#include

#include

#include

Void main (int Argc, char * argv [])

{

INT I;

Printf ("Command Line Arguments: / N");

For (i = 0; I Printf ("[% 2D]:% S / N", I, ARGV);

Printf ("About to Exec Child With Arg1 Arg2 ... / N");

Execv ("Child.exe", Argv);

Perror ("Exec Error");

Exit (1);

}

Function name: exit

Function: Termination Program

Usage: void exit; Int status;

Example:

#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);

Example:

#include

#include

Int main (void)

{

Double Result;

Double X = 4.0;

Result = EXP (x);

Printf ("e raised to the power /

OF% LF (E ^% lf) =% lf / n ",

X, x, result);

Return 0;

}

Function Daquan (beginning)

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 bring

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); open the stream with a file description word. FDOpen makes streaming stream with a file description word obtained from Creat, DUP, DUP2 or OPEN

related. 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); Clears buffers of the input stream, so that it is still open, and writes the contents of the buffer of the output stream to 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 N-1 characters from the stream Stream, or exchange the information, and store the read content, stored in S. Unlike gets, FGETs are not reserved at S

Removal. 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. With (x, y), XRADIUS and YRADIUS are horizontal and vertical half-axis, with the current color drawing edge line, draw an ellipse, with the current fill color and

Fill 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 and write all the contents of the buffer that open the output stream to the respective files

, Read the new data from the input file to the buffer from the input file. 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. If DRIVE gives x:, DIR gives / dir / subdir /, name gives Name, and .ext gives .ext, according to a given component, you can build a

The full panel path file name path is: x: /dir/cubdir/name.ext int Fnsplit (const char * path, char * drive, char * CIR, Char * name, char * ext); you can give Path The extension of the panel path file name extension is decomposed into 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 are: r, open for reading; W, open for writing; A, open for writing after the original content; R , open existing

The file is used to update (read and write); W creation new file is used to update; A , open it for updating after the original content, if the file does not exist

create.

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); writing a character to the stream. Returns the written characters when successful, returns EOF when you fail.

INT fputchar (int C); send a character to the screen. Equivalent to FPUTC (C, stdout); return to EOF when successfully returning the word, fail, or error.

INT FPUTS (Const Char * S, File * Stream); feeds S, empty characters ended in the stream, does not turn the line characters / N, not copy string endors / 0.

Returns the last character when successfully, returns EOF when an error is wrong.

SIZE_T FREAD (Void * PTR, SIZE_T SIZE, SIZE_T N, FILE * STREAM); N items read from the give stream stream, each data length is a size byte, to blocks referred to by PTR in. When successful, return the number of data items (not bytes); if you encounter files, you may return 0 when an error occurs. Void Free (Void * Block); Release the previously assigned first address of 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% open

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 imce); repositions the location of the file structure on the stream. FSEEK Sets the file pointer to the stream Stream to the new location, the new location is given for gence

The distance of the file location is OFFSet bytes. The value of WHENCE must be one of 0, 1 or 2, which represents three symbol constants defined in stdio.h, respectively: 0 is seek_set, 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 an input; or an output. When moving successfully,

FSeek returns 0; returns a non-0 value when an error or failure. Example: #include file * stream; void main (void) {long L; float fp; char s; 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 FSETPOS (File * Stream, Const fpos_t * POS ); FSETPOS places the file pointer to the Stream in a new location. This new location is the value of the previously obtained FGETPOS. FSETPOS Clears the file end flag of the file finger finger file finger, and eliminate all the files UNGETC operation. After calling FSETPOS,

The next operation of the part can be an input or output. Return 0 when calling FSETPOS; if it fails, return a non-0 value.

INT FSTAT (INT HANDLE, STRUCT Stat * Statbuf); stores information of open files or directories associated with the handle to the STAT structure referred to in STATBUF in sys / stat.h. Be successful

Returns 0; Returns -1 when an error is wrong. Long Int Ftell (File * Stream); Returns the current file pointer position in Stream Street. The offset is the number of bytes that the file begins. Returns -1L at the time of error, is the -1 value of the long integer. Void ftime (struct timeb * buf); stored the current time into the TIMEB structure defined in sys / timeb.h.

SIZE_T FWRITE (const void * ptr, size_t size, size_t n, file * stream); FWRITE starts to add N data items from the pointer PTR to a given output stream Stream, and each data item is SIZE byte. Success is to return the exact data item (not byte); return a short (Short) count value when an error is wrong. It may be 0.

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

New Post(0)