C language function finishing Daquan three (F-G)

Source: Internet
Author: User

Function Name: ecvt
Function: converts a floating point number to a string.
Usage: char ecvt (double value, int ndigit, int * decpt, int * sign );
Program example:
# Include
# Include
# Include
Int main (void)
{
Char * string;
Double value;
Int dec, sign;
Int ndig = 10;
Clrscr ();
Values = 9.876;
String = ecvt (value, ndig, & dec, & sign );
Printf ("string = % s dec = % d
Sign = % d ", string, dec, sign );
Value =-123.45;
Ndig = 15;
String = ecvt (value, ndig, & dec, & sign );
Printf ("string = % s dec = % d sign = % d ",
String, dec, sign );

Value = 0.6789e5;/* scientific
Notation */
Ndig = 5;
String = ecvt (value, ndig, & dec, & sign );
Printf ("string = % s dec = % d
Sign = % d ", string, dec, sign );
Return 0;
}

Function Name: ellipse
Skill: draw an ellipse
Usage: void far ellipse (int x, int y, int stangle, int endangle,
Int xradius, int yradius );
Program 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 initialization */
Errorcode = graphresult ();
If (errorcode! = GrOk)
/* An error occurred */
{
Printf ("Graphics error: % s ",
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: Enable hardware interruption
Usage: void enable (void );
Program 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 will
Operate correctly.
*/
# Include
# Include
# Include
/* The clock tick 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 interrupt handler */
Setvect (INTR, handler );
/* Loop until the counter exceeds 20 */
While (count <20)
Printf ("count is % d", count );
/* Reset the old interrupt handler */
Setvect (INTR, oldhandler );
Return 0;
}

Function Name: eof
Function: End of detection File
Usage: int eof (int * handle );
Program 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...
Functions: load and run functions of 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 []);
Program example:
/* Execv example */
# Include
# Include
# Include
Void main (int argc, char * argv [])
{
Int I;
Printf ("Command line arguments :");
For (I = 0; I
Printf ("[-]: % s", I, argv [I]);
Printf ("About to exec child with arg1 arg2 ...");
Execv ("CHILD. EXE", argv );
Perror ("exec error ");
Exit (1 );
}

Function Name: exit
Function: Terminate the program
Usage: void exit (int status );
Program example:
# Include
# Include
# Include
Int main (void)
{
Int status;
Printf ("Enter either 1 or 2 ");
Status = getch ();
/* Sets DOS errorlevel */
Exit (status-'0 ');
/* Note: this line is never reached */
Return 0;
}

Function Name: gcvt

Function: converts a floating point to a string.

Usage: char * gcvt (double value, int ndigit, char * buf );

Program example:

#include
#include
int main(void)
{
char str[25];
double num;
int sig = 5; /* significant digits */
/* a regular number */
num = 9.876;
gcvt(num, sig, str);
printf("string = %s", str);
/* a negative number */
num = -123.4567;
gcvt(num, sig, str);
printf("string = %s", str);
/* scientific notation */
num = 0.678e5;
gcvt(num, sig, str);
printf("string = %s", str);
return(0);
}


Function Name: geninterrupt

Power: generate a Soft Interrupt

Usage: void geninterrupt (int intr_num );

Program example:

#include
#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

Power: get the coordinates of the last called arc

Usage: void far getarccoords (struct arccoordstype far * arccoords );

Program example:

#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
struct arccoordstype arcinfo;
int midx, midy;
int stangle = 45, endangle = 270;
char sstr[80], estr[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* draw arc and get coordinates */
setcolor(getmaxcolor());
arc(midx, mi

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.