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/n", 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, midy, stangle, endangle, 100); getarccoords(&arcinfo);
/* convert arc information into strings */ sprintf(sstr, "*- (%d, %d)", arcinfo.xstart, arcinfo.ystart); sprintf(estr, "*- (%d, %d)", arcinfo.xend, arcinfo.yend);
/* output the arc information */ outtextxy(arcinfo.xstart, arcinfo.ystart, sstr); outtextxy(arcinfo.xend, arcinfo.yend, estr);
/* clean up */ getch(); closegraph(); return 0; }
函数名: getaspectratio 功 能: 返回当前图形模式的纵横比 用 法: void far getaspectratio(int far *xasp, int far *yasp); 程序例:
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xasp, yasp, midx, midy;
/* 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(); /* terminate with an error code */ exit(1); }
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int bkcolor, midx, midy; char bkname[35];
/* 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(); /* terminate with an error code */ exit(1); }
printf("Input a character:"); /* read a character from the standard input stream */ ch = getc(stdin); printf("The character input was: '%c'/n", ch); return 0; }
函数名: getcbrk 功 能: 获取Control_break设置 用 法: int getcbrk(void); 程序例:
#include <stdio.h> #include <dos.h>
int main(void) { if (getcbrk()) printf("Cntrl-brk flag is on/n"); else printf("Cntrl-brk flag is off/n");
return 0; }
函数名: getch 功 能: 从控制台无回显地取一个字符 用 法: int getch(void); 程序例:
#include <stdio.h> #include <conio.h>
int main(void) { char ch;
printf("Input a character:"); ch = getche(); printf("/nYou input a '%c'/n", ch); return 0; }
函数名: getchar 功 能: 从stdin流中读字符 用 法: int getchar(void); 程序例:
#include <stdio.h>
int main(void) { int c;
/* Note that getchar reads from stdin and is line buffered; this means it will not return until you press ENTER. */
while ((c = getchar()) != '/n') printf("%c", c);
return 0; }
函数名: getche 功 能: 从控制台取字符(带回显) 用 法: int getche(void); 程序例:
#include <stdio.h> #include <conio.h>
int main(void) { char ch;
printf("Input a character:"); ch = getche(); printf("/nYou input a '%c'/n", ch); return 0; }
函数名: getcolor 功 能: 返回当前画线颜色 用 法: int far getcolor(void); 程序例:
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int color, midx, midy; char colname[35];
/* 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(); /* terminate with an error code */ exit(1); }
char *current_Directory(char *path) { strcpy(path, "X://"); /* fill string with form of response: X:/ */ path[0] = 'A' + getdisk(); /* replace X with current drive letter */ getcurdir(0, path+3); /* fill rest of string with current directory */ return(path); }
int main(void) { char curdir[MAXPATH];
current_directory(curdir); printf("The current directory is %s/n", curdir);