C language library function Daquan (letter a) --- instructions for use (conversion) -- Linux general technology-Linux programming and kernel information, the following is read details. Function Name: abort
Function: terminates a process abnormally.
Usage: void abort (void );
Program example:
# Include
# Include
Int main (void)
{
Printf ("Calling abort () \ n ");
Abort ();
Return 0;/* This is never reached */
}
Function Name: abs
Function: Calculate the absolute value of an integer.
Usage: int abs (int I );
Program example:
# Include
# Include
Int main (void)
{
Int number =-1234;
Printf ("number: % d absolute value: % d \ n", number, abs (number ));
Return 0;
}
Function Name: absread, abswirte
Functions: Read and Write Data in absolute disk sectors
Usage: int absread (int drive, int nsects, int sectno, void * buffer );
Int abswrite (int drive, int nsects, in tsectno, void * buffer );
Program example:
/* Absread example */
# Include
# Include
# Include
# Include
Int main (void)
{
Int I, strt, ch_out, sector;
Char buf [512];
Printf ("Insert a diskette into drive A and press any key \ n ");
Getch ();
Sector = 0;
If (absread (0, 1, sector, & buf )! = 0)
{
Perror ("Disk problem ");
Exit (1 );
}
Printf ("Read OK \ n ");
Strt = 3;
For (I = 0; I <80; I ++)
{
Ch_out = buf [strt + I];
Putchar (ch_out );
}
Printf ("\ n ");
Return (0 );
}
Function Name: access
Skill: determine the object access permission
Usage: int access (const char * filename, int amode );
Program example:
# 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;
}
Function Name: acos
Function: arccosine Function
Usage: double acos (double x );
Program example:
# 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: allocate DOS storage segments
Usage: int allocmem (unsigned size, unsigned * seg );
Program example:
# Include
# Include
# Include
Int main (void)
{
Unsigned int size, segp;
Int stat;
Size = 64;/* (64x16) = 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
Power: draw an arc
Usage: void far arc (int x, int y, int stangle, int endangle, int radius );
Program example:
# Include
# Include
# Include
# Include
Int main (void)
{
/* Request auto detection */
Int gdriver = DETECT, gmode, errorcode;
Int midx, midy;
Int stangle = 45, endangle = 135;
Int radius = 100;
/* Initialize graphics and local variables */
Initgraph (& gdriver, & gmode ,"");
/* Read 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 ();
Function Name: asctime
Function: Convert the date and time into ASCII codes.
Usage: char * asctime (const struct tm * tblock );
Program example:
# Include
# Include
# Include
Int main (void)
{
Struct tm t;
Char str [80];
/* Sample loading of tm structure */
T. tm_sec = 1;/* Seconds */
T. tm_min = 30;/* Minutes */
T. tm_hour = 9;/* Hour */
T. tm_mday = 22;/* Day of the Month */
T. tm_mon = 11;/* Month */
T. tm_year = 56;/* Year-does not include century */
T. tm_wday = 4;/* Day of the week */
T. tm_yday = 0;/* Does not show in asctime */
T. tm_isdst = 0;/* Is Daylight SavTime; does not show in asctime */
/* Converts structure to null terminated
String */
Strcpy (str, asctime (& t ));
Printf ("% s \ n", str );
Return 0;
}
Function Name: asin
Power: arcsin Function
Usage: double asin (double x );
Program example:
# 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
Skill: test a condition and possibly terminate the program
Usage: void assert (int test );
Program example:
# Include
# Include
# Include
Struct ITEM {
Int key;
Int value;
};
/* Add item to list, make sure list is not null */
Void additem (struct ITEM * itemptr ){
Assert (itemptr! = NULL );
/* Add item to list */
}
Int main (void)
{
Additem (NULL );
Return 0;
}
Function Name: atan
Function: returns the arc tangent function.
Usage: double atan (double x );
Program example:
# Include
# Include
Int main (void)
{
Double result;
Double x = 0.5;
Result = atan (x );
Printf ("The arc tangent of % lf is % lf \ n", x, result );
Return (0 );
}
Function Name: atan2
Function: Calculate the arc tangent value of Y/X.
Usage: double atan2 (double y, double x );
Program example:
# Include
# Include
Int main (void)
{
Double result;
Double x = 90.0, y = 45.0;
Result = atan2 (y, x );
Printf ("The arc tangent ratio of % lf is % lf \ n", (y/x), result );
Return 0;
}
Function Name: atexit
Function: register the termination function.
Usage: int atexit (atexit_t func );
Program example:
# 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: converts a string to a floating point number.
Usage: double atof (const char * nptr );
Program example:
# 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: converts a string to an integer.
Usage: int atoi (const char * nptr );
Program example:
# 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: converts a string to an integer.
Usage: long atol (const char * nptr );
Program example:
# Include
# Include
Int main (void)
{
Long l;
Char * str = "98765432 ";
L = atol (lstr );
Printf ("string = % s integer = % ld \ n", str, l );
Return (0 );
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.