?? g.htm
字號:
<PRE>void interrupt get_out(); /* interrupt prototype */ </PRE>
<PRE>void interrupt (*oldfunc)(); /* interrupt function pointer */
int looping = 1; </PRE>
<PRE>int main(void)
{
puts("Press to terminate"); </PRE>
<PRE>/* save the old interrupt */
oldfunc = getvect(5); </PRE>
<PRE>/* install interrupt handler */
setvect(5,get_out); </PRE>
<PRE>/* do nothing */
while (looping); </PRE>
<PRE>/* restore to original interrupt routine */
setvect(5,oldfunc); </PRE>
<PRE>puts("Success");
return 0;
}
void interrupt get_out()
{
looping = 0; /* change global variable to get out of loop */
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">getverify </font>
功 能: 返回DOS校驗(yàn)標(biāo)志狀態(tài)
用 法: int getverify(void);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>int main(void)
{
if (getverify())
printf("DOS verify flag is on\n");
else
printf("DOS verify flag is off\n");
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">getviewsetting </font>
功 能: 返回有關(guān)當(dāng)前視區(qū)的信息
用 法: void far getviewsettings(struct viewporttype far *viewport);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>char *clip[] = { "OFF", "ON" }; </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
struct viewporttype viewinfo;
int midx, midy, ht;
char topstr[80], botstr[80], clipstr[80]; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>midx = getmaxx() / 2;
midy = getmaxy() / 2; </PRE>
<PRE>/* get information about current viewport */
getviewsettings(&viewinfo); </PRE>
<PRE>/* convert text information into strings */
sprintf(topstr, "(%d, %d) is the upper left viewport corner.",
viewinfo.left, viewinfo.top);
sprintf(botstr, "(%d, %d) is the lower right viewport corner.",
viewinfo.right, viewinfo.bottom);
sprintf(clipstr, "Clipping is turned %s.", clip[viewinfo.clip]); </PRE>
<PRE>/* display the information */
settextjustify(CENTER_TEXT, CENTER_TEXT);
ht = textheight("W");
outtextxy(midx, midy, topstr);
outtextxy(midx, midy+2*ht, botstr);
outtextxy(midx, midy+4*ht, clipstr); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">getw </font>
功 能: 從流中取一整數(shù)
用 法: int getw(FILE *strem);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>#define FNAME "test.$$$" </PRE>
<PRE>int main(void)
{
FILE *fp;
int word; </PRE>
<PRE>/* place the word in a file */
fp = fopen(FNAME, "wb");
if (fp == NULL)
{
printf("Error opening file %s\n", FNAME);
exit(1);
} </PRE>
<PRE>word = 94;
putw(word,fp);
if (ferror(fp))
printf("Error writing to file\n");
else
printf("Successful write\n");
fclose(fp); </PRE>
<PRE>/* reopen the file */
fp = fopen(FNAME, "rb");
if (fp == NULL)
{
printf("Error opening file %s\n", FNAME);
exit(1);
} </PRE>
<PRE>/* extract the word */
word = getw(fp);
if (ferror(fp))
printf("Error reading file\n");
else
printf("Successful read: word = %d\n", word); </PRE>
<PRE>/* clean up */
fclose(fp);
unlink(FNAME); </PRE>
<PRE>return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">getx </font>
功 能: 返回當(dāng)前圖形位置的x坐標(biāo)
用 法: int far getx(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80]; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>/* move to the screen center point */
moveto(getmaxx() / 2, getmaxy() / 2); </PRE>
<PRE>/* create a message string */
sprintf(msg, "<-(%d, %d) is the here.", getx(), gety()); </PRE>
<PRE>/* display the message */
outtext(msg); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">gety </font>
功 能: 返回當(dāng)前圖形位置的y坐標(biāo)
用 法: int far gety(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80]; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>/* move to the screen center point */
moveto(getmaxx() / 2, getmaxy() / 2); </PRE>
<PRE>/* create a message string */
sprintf(msg, "<-(%d, %d) is the here.", getx(), gety()); </PRE>
<PRE>/* display the message */
outtext(msg); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">gmtime </font>
功 能: 把日期和時(shí)間轉(zhuǎn)換為格林尼治標(biāo)準(zhǔn)時(shí)間(GMT)
用 法: struct tm *gmtime(long *clock);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>/* Pacific Standard Time & Daylight Savings */
char *tzstr = "TZ=PST8PDT"; </PRE>
<PRE>int main(void)
{
time_t t;
struct tm *gmt, *area; </PRE>
<PRE>putenv(tzstr);
tzset(); </PRE>
<PRE>t = time(NULL);
area = localtime(&t);
printf("Local time is: %s", asctime(area));
gmt = gmtime(&t);
printf("GMT is: %s", asctime(gmt));
return 0;
}
</PRE>
<PRE>函數(shù)名:<font size="5" color="#FF0000"> gotoxy </font>
功 能: 在文本窗口中設(shè)置光標(biāo)
用 法: void gotoxy(int x, int y);
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void)
{
clrscr();
gotoxy(35, 12);
cprintf("Hello world");
getch();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">gotoxy </font>
功 能: 在文本窗口中設(shè)置光標(biāo)
用 法: void gotoxy(int x, int y);
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void)
{
clrscr();
gotoxy(35, 12);
cprintf("Hello world");
getch();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">graphdefaults</font>
功 能: 將所有圖形設(shè)置復(fù)位為它們的缺省值
用 法: void far graphdefaults(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\\bor\\Borland\\bgi"); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>maxx = getmaxx();
maxy = getmaxy(); </PRE>
<PRE>/* output line with non-default settings */
setlinestyle(DOTTED_LINE, 0, 3);
line(0, 0, maxx, maxy);
outtextxy(maxx/2, maxy/3, "Before default values are restored.");
getch(); </PRE>
<PRE>/* restore default values for everything */
graphdefaults(); </PRE>
<PRE>/* clear the screen */
cleardevice(); </PRE>
<PRE>/* output line with default settings */
line(0, 0, maxx, maxy);
outtextxy(maxx/2, maxy/3, "After restoring default values."); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">grapherrormsg </font>
功 能: 返回一個(gè)錯(cuò)誤信息串的指針
用 法: char *far grapherrormsg(int errorcode);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>#define NONSENSE -50 </PRE>
<PRE>int main(void)
{
/* FORCE AN ERROR TO OCCUR */
int gdriver = NONSENSE, gmode, errorcode; </PRE>
<PRE>/* initialize graphics mode */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult(); </PRE>
<PRE>/* if an error occurred, then output a */
/* descriptive error message. */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
} </PRE>
<PRE>/* draw a line */
line(0, 0, getmaxx(), getmaxy()); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">graphresult </font>
功 能: 返回最后一次不成功的圖形操作的錯(cuò)誤代碼
用 法: int far graphresult(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult(); </PRE>
<PRE>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 */
} </PRE>
<PRE>/* draw a line */
line(0, 0, getmaxx(), getmaxy()); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">_graphfreemem </font>
功 能: 用戶可修改的圖形存儲區(qū)釋放函數(shù)
用 法: void far _graphfreemem(void far *ptr, unsigned size);
程序例: </PRE>
<PRE>#include
#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy; </PRE>
<PRE>/* clear the text screen */
clrscr();
printf("Press any key to initialize graphics mode:");
getch();
clrscr(); </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>midx = getmaxx() / 2;
midy = getmaxy() / 2; </PRE>
<PRE>/* display a message */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, "Press any key to exit graphics mode:"); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
} </PRE>
<PRE>/* called by the graphics kernel to allocate memory */
void far * far _graphgetmem(unsigned size)
{
printf("_graphgetmem called to allocate %d bytes.\n", size);
printf("hit any key:");
getch();
printf("\n"); </PRE>
<PRE>/* allocate memory from far heap */
return farmalloc(size);
} </PRE>
<PRE>/* called by the graphics kernel to free memory */
void far _graphfreemem(void far *ptr, unsigned size)
{
printf("_graphfreemem called to free %d bytes.\n", size);
printf("hit any key:");
getch();
printf("\n"); </PRE>
<PRE>/* free ptr from far heap */
farfree(ptr);
}
</PRE>
<PRE>函數(shù)名: _<font size="5" color="#FF0000">graphgetmem </font>
功 能: 用戶可修改的圖形存儲區(qū)分配函數(shù)
用 法: void far *far _graphgetmem(unsigned size);
程序例: </PRE>
<PRE>#include
#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy; </PRE>
<PRE>/* clear the text screen */
clrscr();
printf("Press any key to initialize graphics mode:");
getch();
clrscr(); </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
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 */
} </PRE>
<PRE>midx = getmaxx() / 2;
midy = getmaxy() / 2; </PRE>
<PRE>/* display a message */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, "Press any key to exit graphics mode:"); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
} </PRE>
<PRE>/* called by the graphics kernel to allocate memory */
void far * far _graphgetmem(unsigned size)
{
printf("_graphgetmem called to allocate %d bytes.\n", size);
printf("hit any key:");
getch();
printf("\n"); </PRE>
<PRE>/* allocate memory from far heap */
return farmalloc(size);
} </PRE>
<PRE>/* called by the graphics kernel to free memory */
void far _graphfreemem(void far *ptr, unsigned size)
{
printf("_graphfreemem called to free %d bytes.\n", size);
printf("hit any key:");
getch();
printf("\n"); </PRE>
<PRE>/* free ptr from far heap */
farfree(ptr);
}</PRE>
<p> </p>
<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>
<pre> </pre>
<pre>資料收集:beck Copyright 2004 張求熙, All Rights Reserved</pre>
<pre><a href="mailto:Email:qiuxi1984@126.com">Email:qiuxi1984@126.com</a> QQ:35540948 </pre>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -