📄 fc.htm
字号:
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error
occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", grapherrormsg(errorcode)); <br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); /* terminate with
an error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; <br>
setcolor(getmaxcolor()); </p>
<p> /* for centering screen messages */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); </p>
<p> /* output a message to the screen */ <br>
outtextxy(midx, midy, "press any key to
clear the screen:"); </p>
<p> /* wait for a key */ <br>
getch(); </p>
<p> /* clear the screen */ <br>
cleardevice(); </p>
<p> /* output another message */ <br>
outtextxy(midx, midy, "press any key to
quit:"); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: clearerr <br>
功 能: 复位错误标志 <br>
用 法:void clearerr(FILE *stream); <br>
程序例: </p>
<p>#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
FILE *fp; <br>
char ch; </p>
<p> /* open a file for writing */ <br>
fp = fopen("DUMMY.FIL",
"w"); </p>
<p> /* force an error condition by attempting
to read */ <br>
ch = fgetc(fp); <br>
printf("%c\n",ch); </p>
<p> if (ferror(fp)) <br>
{ <br>
/* display an error
message */ <br>
printf("Error reading
from DUMMY.FIL\n"); </p>
<p> /* reset the error and
EOF indicators */ <br>
clearerr(fp); <br>
} </p>
<p> fclose(fp); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: clearviewport <br>
功 能: 清除图形视区 <br>
用 法: void far clearviewport(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>#define CLIP_ON 1 /* activates clipping in
viewport */ </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int ht; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error
occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", grapherrormsg(errorcode)); <br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); /* terminate with
an error code */ <br>
} </p>
<p> setcolor(getmaxcolor()); <br>
ht = textheight("W"); </p>
<p> /* message in default full-screen
viewport */ <br>
outtextxy(0, 0, "* <-- (0, 0) in
default viewport"); </p>
<p> /* create a smaller viewport */ <br>
setviewport(50, 50, getmaxx()-50,
getmaxy()-50, CLIP_ON); </p>
<p> /* display some messages */ <br>
outtextxy(0, 0, "* <-- (0, 0) in
smaller viewport"); <br>
outtextxy(0, 2*ht, "Press any key to
clear viewport:"); </p>
<p> /* wait for a key */ <br>
getch(); </p>
<p> /* clear the viewport */ <br>
clearviewport(); </p>
<p> /* output another message */ <br>
outtextxy(0, 0, "Press any key to
quit:"); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: _close, close <br>
功 能: 关闭文件句柄 <br>
用 法: int close(int handle); <br>
程序例: </p>
<p>#include <string.h> <br>
#include <stdio.h> <br>
#include <fcntl.h> <br>
#include <io.h> </p>
<p>main() <br>
{ <br>
int handle; <br>
char buf[11] = "0123456789"; </p>
<p> /* create a file containing 10 bytes */ <br>
handle = open("NEW.FIL", O_CREAT);
<br>
if (handle > -1) <br>
{ <br>
write(handle, buf,
strlen(buf)); </p>
<p> /* close the file
*/ <br>
close(handle); <br>
} <br>
else <br>
{ <br>
printf("Error
opening file\n"); <br>
} <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: clock <br>
功 能: 确定处理器时间 <br>
用 法: clock_t clock(void); <br>
程序例: </p>
<p>#include <time.h> <br>
#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
clock_t start, end; <br>
start = clock(); </p>
<p> delay(2000); </p>
<p> end = clock(); <br>
printf("The time was: %f\n", (end
- start) / CLK_TCK); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: closegraph <br>
功 能: 关闭图形系统 <br>
用 法: void far closegraph(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int x, y; </p>
<p> /* initialize graphics mode */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); </p>
<p> if (errorcode != grOk) /* an error <br>
occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", grapherrormsg(errorcode)); <br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); /* terminate with
an error code */ <br>
} </p>
<p> x = getmaxx() / 2; <br>
y = getmaxy() / 2; </p>
<p> /* output a message */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(x, y, "Press a key to close
the graphics system:"); </p>
<p> /* wait for a key */ <br>
getch(); </p>
<p> /* closes down the graphics system */ <br>
closegraph(); </p>
<p> printf("We're now back in text
mode.\n"); <br>
printf("Press any key to halt:"); <br>
getch(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: clreol <br>
功 能: 在文本窗口中清除字符到行末 <br>
用 法: void clreol(void); <br>
程序例: </p>
<p>#include <conio.h> </p>
<p>int main(void) </p>
<p>{ <br>
clrscr(); <br>
cprintf("The function CLREOL clears all
characters from the\r\n"); <br>
cprintf("cursor position to the end of
the line within the\r\n"); <br>
cprintf("current text window, without
moving the cursor.\r\n"); <br>
cprintf("Press any key to continue . .
."); <br>
gotoxy(14, 4); <br>
getch(); </p>
<p> clreol(); <br>
getch(); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: clrscr <br>
功 能: 清除文本模式窗口 <br>
用 法: void clrscr(void); <br>
程序例: </p>
<p>#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
int i; </p>
<p> clrscr(); <br>
for (i = 0; i < 20; i++) <br>
cprintf("%d\r\n", i); <br>
cprintf("\r\nPress any key to clear
screen"); <br>
getch(); </p>
<p> clrscr(); <br>
cprintf("The screen has been
cleared!"); <br>
getch(); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: coreleft <br>
功 能: 返回未使用内存的大小 <br>
用 法: unsigned coreleft(void); <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -