?? fg.htm
字號:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META NAME="Author" CONTENT="wdg">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">
<TITLE>fg</TITLE>
</HEAD>
<BODY>
<P>函數名: gcvt
<BR>功 能: 把浮點數轉換成字符串
<BR>用 法: char *gcvt(double value, int ndigit, char *buf);
<BR>程序例:
<P>#include <stdlib.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> char str[25];
<BR> double num;
<BR> int sig = 5; /* significant digits */
<P> /* a regular number */
<BR> num = 9.876;
<BR> gcvt(num, sig, str);
<BR> printf("string = %s\n", str);
<P> /* a negative number */
<BR> num = -123.4567;
<BR> gcvt(num, sig, str);
<BR> printf("string = %s\n", str);
<P> /* scientific notation */
<BR> num = 0.678e5;
<BR> gcvt(num, sig, str);
<BR> printf("string = %s\n", str);
<P> return(0);
<BR>}
<BR>
<BR>
<BR>
<P>函數名: geninterrupt
<BR>功 能: 產生一個軟中斷
<BR>用 法: void geninterrupt(int intr_num);
<BR>程序例:
<P>#include <conio.h>
<BR>#include <dos.h>
<P>/* function prototype */
<BR>void writechar(char ch);
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> gotoxy(80,25);
<BR> writechar('*');
<BR> getch();
<BR> return 0;
<BR>}
<P>/*
<BR> outputs a character at the current cursor
<BR> position using the video BIOS to avoid the
<BR> scrolling of the screen when writing to
<BR> location (80,25).
<BR>*/
<P>void writechar(char ch)
<BR>{
<BR> struct text_info ti;
<BR> /* grab current text settings */
<BR> gettextinfo(&ti);
<BR> /* interrupt 0x10 sub-function 9 */
<BR> _AH = 9;
<BR> /* character to be output */
<BR> _AL = ch;
<BR> _BH = 0;
/* video page */
<BR> _BL = ti.attribute; /* video attribute */
<BR> _CX = 1;
/* repetition factor */
<BR> geninterrupt(0x10); /* output the char */
<BR>}
<BR>
<BR>
<P>函數名: getarccoords
<BR>功 能: 取得最后一次調用arc的坐標
<BR>用 法: void far getarccoords(struct arccoordstype far *arccoords);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR>/* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> struct arccoordstype arcinfo;
<BR> int midx, midy;
<BR> int stangle = 45, endangle = 270;
<BR> char sstr[80], estr[80];
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P>/* draw arc and get coordinates */
<BR> setcolor(getmaxcolor());
<BR> arc(midx, midy, stangle, endangle, 100);
<BR> getarccoords(&arcinfo);
<P>/* convert arc information into strings */
<BR> sprintf(sstr, "*- (%d, %d)",
<BR> arcinfo.xstart,
arcinfo.ystart);
<BR> sprintf(estr, "*- (%d, %d)",
<BR> arcinfo.xend,
arcinfo.yend);
<P> /* output the arc information */
<BR> outtextxy(arcinfo.xstart,
<BR>
arcinfo.ystart, sstr);
<BR> outtextxy(arcinfo.xend,
<BR>
arcinfo.yend, estr);
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: getaspectratio
<BR>功 能: 返回當前圖形模式的縱橫比
<BR>用 法: void far getaspectratio(int far *xasp, int far *yasp);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR>/* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int xasp, yasp, midx, midy;
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<BR> setcolor(getmaxcolor());
<P>/* get current aspect ratio settings */
<BR> getaspectratio(&xasp, &yasp);
<P>/* draw normal circle */
<BR> circle(midx, midy, 100);
<BR> getch();
<P>/* draw wide circle */
<BR> cleardevice();
<BR> setaspectratio(xasp/2, yasp);
<BR> circle(midx, midy, 100);
<BR> getch();
<P>/* draw narrow circle */
<BR> cleardevice();
<BR> setaspectratio(xasp, yasp/2);
<BR> circle(midx, midy, 100);
<P>/* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: getbkcolor
<BR>功 能: 返回當前背景顏色
<BR>用 法: int far getbkcolor(void);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int bkcolor, midx, midy;
<BR> char bkname[35];
<P>/* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P>/* read result of initialization */
<BR> errorcode = graphresult();
<BR>/* an error occurred */
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n",
<BR>
grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR>/* terminate with an error code */
<BR> exit(1);
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<BR> setcolor(getmaxcolor());
<P>/* for centering text on the display */
<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);
<P>/* get the current background color */
<BR> bkcolor = getbkcolor();
<P>/* convert color value into a string */
<BR> itoa(bkcolor, bkname, 10);
<BR> strcat(bkname,
<BR> " is the current background color.");
<P>/* display a message */
<BR> outtextxy(midx, midy, bkname);
<P>/* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: getc
<BR>功 能: 從流中取字符
<BR>用 法: int getc(FILE *stream);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> char ch;
<P> printf("Input a character:");
<BR>/* read a character from the
<BR> standard input stream */
<BR> ch = getc(stdin);
<BR> printf("The character input was: '%c'\n",
<BR> ch);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: getcbrk
<BR>功 能: 獲取Control_break設置
<BR>用 法: int getcbrk(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> if (getcbrk())
<BR> printf("Cntrl-brk flag is on\n");
<BR> else
<BR> printf("Cntrl-brk flag is off\n");
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數名: getch
<BR>功 能: 從控制臺無回顯地取一個字符
<BR>用 法: int getch(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> char ch;
<P> printf("Input a character:");
<BR> ch = getche();
<BR> printf("\nYou input a '%c'\n", ch);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: getchar
<BR>功 能: 從stdin流中讀字符
<BR>用 法: int getchar(void);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> int c;
<P> /* Note that getchar reads from stdin and
<BR> is line buffered; this means it will
<BR> not return until you press ENTER. */
<P> while ((c = getchar()) != '\n')
<BR> printf("%c", c);
<P> return 0;
<BR>}
<BR>
<BR>
<P>函數名: getche
<BR>功 能: 從控制臺取字符(帶回顯)
<BR>用 法: int getche(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> char ch;
<P> printf("Input a character:");
<BR> ch = getche();
<BR> printf("\nYou input a '%c'\n", ch);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: getcolor
<BR>功 能: 返回當前畫線顏色
<BR>用 法: int far getcolor(void);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <string.h>
<BR>#include <stdio.h>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -