C language Function Encyclopedia (beginning of G)

Source: Internet
Author: User
Tags function prototype printf

Function Name: GCVT

Function: Converts floating-point numbers to strings

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\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: Produces 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 */
}

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.