C语言函数大全(i开头)

函数名: imagesize

功能: 返回保存位图像所需的字节数

用法: unsigned far imagesize(int left, int top, int right, int bottom);

程序例:

#include
#include
#include
#include
#define ARROW_SIZE 10
void draw_arrow(int x, int y);
int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
void *arrow;
int x, y, maxx;
unsigned int size;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* 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 */
}
maxx = getmaxx();
x = 0;
y = getmaxy() / 2;
/* draw the image to be grabbed */
draw_arrow(x, y);
/* calculate the size of the image */
size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);
/* allocate memory to hold the image */
arrow = malloc(size);
/* grab the image */
getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);
/* repeat until a key is pressed */
while (!kbhit())
{
/* erase old image */
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
x += ARROW_SIZE;
if (x >= maxx)
x = 0;
/* plot new image */
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
}
/* clean up */
free(arrow);
closegraph();
return 0;
}
void draw_arrow(int x, int y)
{
/* draw an arrow on the screen */
moveto(x, y);
linerel(4*ARROW_SIZE, 0);
linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
linerel(0, 2*ARROW_SIZE);
linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
}

时间: 2025-01-30 10:17:36

C语言函数大全(i开头)的相关文章

C语言函数大全(a开头)

函数名: abort 功能: 异常终止一个进程 用法: void abort(void); 程序例: #include #include int main(void) { printf("Calling abort()\n"); abort(); return 0; /* This is never reached */ } 函数名: abs 功能: 求整数的绝对值 用法: int abs(int i); 程序例: #include #include int main(void) {

C语言函数大全(b开头)

函数名: bar 功能: 画一个二维条形图 用法: void far bar(int left, int top, int right, int bottom); 程序例: #include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int midx, midy, i; /* initialize graphics

C语言函数大全(c开头)

函数名: cabs 功能: 计算复数的绝对值 用法: double cabs(struct complex z); 程序例: #include #include int main(void) { struct complex z; double val; z.x = 2.0; z.y = 1.0; val = cabs(z); printf("The absolute value of %.2lfi %.2lfj is %.2lf", z.x, z.y, val); return 0;

C语言函数大全(d开头)

函数名: delay 功能: 将程序的执行暂停一段时间(毫秒) 用法: void delay(unsigned milliseconds); 程序例: /* Emits a 440-Hz tone for 500 milliseconds */ #include int main(void) { sound(440); delay(500); nosound(); return 0; } 函数名: delline 功能: 在文本窗口中删去一行 用法: void delline(void); 程序

C语言函数大全(e开头)

函数名: ecvt 功能: 把一个浮点数转换为字符串 用法: char ecvt(double value, int ndigit, int *decpt, int *sign); 程序例: #include #include #include int main(void) { char *string; double value; int dec, sign; int ndig = 10; clrscr(); value = 9.876; string = ecvt(value, ndig,

C语言函数大全(g开头)

函数名: gcvt 功能: 把浮点数转换成字符串 用法: char *gcvt(double value, int ndigit, char *buf); 程序例: #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("str

C语言函数大全(h开头)

函数名: harderr 功能: 建立一个硬件错误处理程序 用法: void harderr(int (*fptr)()); 程序例: /*This program will trap disk errors and prompt the user for action. Try running it with no disk in drive A: to invoke its functions.*/ #include #include #include #define IGNORE 0 #d

C语言函数大全(k开头)

函数名: kbhit 功能: 检查当前按下的键 用法: int kbhit(void); 程序例: #include int main(void) { cprintf("Press any key to continue:"); while (!kbhit()) /* do nothing */ ; cprintf("\r\nA key was pressed...\r\n"); return 0; } 函数名: keep 功能: 退出并继续驻留 用法: void

C语言函数大全(l开头)

函数名: labs 用法: long labs(long n); 程序例: #include #include int main(void) { long result; long x = -12345678L; result= labs(x); printf("number: %ld abs value: %ld\n", x, result); return 0; } 函数名: ldexp 功能: 计算value*2的幂 用法: double ldexp(double value,