📄 fc.htm
字号:
<BR> write(handle, buf, strlen(buf));
<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>函数名: clock
<BR>功 能: 确定处理器时间
<BR>用 法: clock_t clock(void);
<BR>程序例:
<P>#include <time.h>
<BR>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> clock_t start, end;
<BR> start = clock();
<P> delay(2000);
<P> end = clock();
<BR> printf("The time was: %f\n", (end - start) / CLK_TCK);
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: closegraph
<BR>功 能: 关闭图形系统
<BR>用 法: void far closegraph(void);
<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 x, y;
<P> /* initialize graphics mode */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<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> x = getmaxx() / 2;
<BR> y = getmaxy() / 2;
<P> /* output a message */
<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);
<BR> outtextxy(x, y, "Press a key to close the graphics system:");
<P> /* wait for a key */
<BR> getch();
<P> /* closes down the graphics system */
<BR> closegraph();
<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>函数名: clreol
<BR>功 能: 在文本窗口中清除字符到行末
<BR>用 法: void clreol(void);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<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> clreol();
<BR> getch();
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: clrscr
<BR>功 能: 清除文本模式窗口
<BR>用 法: void clrscr(void);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> int i;
<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> clrscr();
<BR> cprintf("The screen has been cleared!");
<BR> getch();
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: coreleft
<BR>功 能: 返回未使用内存的大小
<BR>用 法: unsigned coreleft(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<P>int main(void)
<BR>{
<BR> printf("The difference between the highest allocated block
and\n");
<BR> printf("the top of the heap is: %lu bytes\n", (unsigned
long) coreleft());
<P> return 0;
<BR>}
<BR>
<P>函数名: cos
<BR>功 能: 余弦函数
<BR>用 法: double cos(double x);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <math.h>
<P>int main(void)
<BR>{
<BR> double result;
<BR> double x = 0.5;
<P> result = cos(x);
<BR> printf("The cosine of %lf is %lf\n", x, result);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: cosh
<BR>功 能: 双曲余弦函数
<BR>用 法: dluble cosh(double x);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <math.h>
<P>int main(void)
<BR>{
<BR> double result;
<BR> double x = 0.5;
<P> result = cosh(x);
<BR> printf("The hyperboic cosine of %lf is %lf\n", x, result);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: country
<BR>功 能: 返回与国家有关的信息
<BR>用 法: struct COUNTRY *country(int countrycode, struct country
*country);
<BR>程序例:
<P>#include <dos.h>
<BR>#include <stdio.h>
<P>#define USA 0
<P>int main(void)
<BR>{
<BR> struct COUNTRY country_info;
<P> country(USA, &country_info);
<BR> printf("The currency symbol for the USA is: %s\n",
<BR> country_info.co_curr);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: cprintf
<BR>功 能: 送格式化输出至屏幕
<BR>用 法: int cprintf(const char *format[, argument, ...]);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* clear the screen */
<BR> clrscr();
<P> /* create a text window */
<BR> window(10, 10, 80, 25);
<P> /* output some text in the window */
<BR> cprintf("Hello world\r\n");
<P> /* wait for a key */
<BR> getch();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: cputs
<BR>功 能: 写字符到屏幕
<BR>用 法: void cputs(const char *string);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* clear the screen */
<BR> clrscr();
<P> /* create a text window */
<BR> window(10, 10, 80, 25);
<P> /* output some text in the window */
<BR> cputs("This is within the window\r\n");
<P> /* wait for a key */
<BR> getch();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: _creat creat
<BR>功 能: 创建一个新文件或重写一个已存在的文件
<BR>用 法: int creat (const char *filename, int permiss);
<BR>程序例:
<P>#include <sys\stat.h>
<BR>#include <string.h>
<BR>#include <fcntl.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int handle;
<BR> char buf[11] = "0123456789";
<P> /* change the default file mode from text to binary */
<BR> _fmode = O_BINARY;
<P> /* create a binary file for reading and writing */
<BR> handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE);
<P> /* write 10 bytes to the file */
<BR> write(handle, buf, strlen(buf));
<P> /* close the file */
<BR> close(handle);
<BR> return 0;
<BR>}
<BR>
<P>函数名: creatnew
<BR>功 能: 创建一个新文件
<BR>用 法: int creatnew(const char *filename, int attrib);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <errno.h>
<BR>#include <dos.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int handle;
<BR> char buf[11] = "0123456789";
<P> /* attempt to create a file that doesn't already exist
*/
<BR> handle = creatnew("DUMMY.FIL", 0);
<P> if (handle == -1)
<BR> printf("DUMMY.FIL already exists.\n");
<BR> else
<BR> {
<BR> printf("DUMMY.FIL successfully created.\n");
<BR> write(handle, buf, strlen(buf));
<BR> close(handle);
<BR> }
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: creattemp
<BR>功 能: 创建一个新文件或重写一个已存在的文件
<BR>用 法: int creattemp(const char *filename, int attrib);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int handle;
<BR> char pathname[128];
<P> strcpy(pathname, "\\");
<P> /* create a unique file in the root directory */
<BR> handle = creattemp(pathname, 0);
<P> printf("%s was the unique file created.\n", pathname);
<BR> close(handle);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: cscanf
<BR>功 能: 从控制台执行格式化输入
<BR>用 法: int cscanf(char *format[,argument, ...]);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> char string[80];
<P> /* clear the screen */
<BR> clrscr();
<P> /* Prompt the user for input */
<BR> cprintf("Enter a string with no spaces:");
<P> /* read the input */
<BR> cscanf("%s", string);
<P> /* display what was read */
<BR> cprintf("\r\nThe string entered is: %s", string);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: ctime
<BR>功 能: 把日期和时间转换为字符串
<BR>用 法: char *ctime(const time_t *time);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <time.h>
<P>int main(void)
<BR>{
<BR> time_t t;
<P> time(&t);
<BR> printf("Today's date and time: %s\n", ctime(&t));
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函数名: ctrlbrk
<BR>功 能: 设置Ctrl-Break处理程序
<BR>用 法: void ctrlbrk(*fptr)(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>#define ABORT 0
<P>int c_break(void)
<BR>{
<BR> printf("Control-Break pressed. Program aborting
...\n");
<BR> return (ABORT);
<BR>}
<P>int main(void)
<BR>{
<BR> ctrlbrk(c_break);
<BR> for(;;)
<BR> {
<BR> printf("Looping... Press <Ctrl-Break>
to quit:\n");
<BR> }
<BR> return 0;
<BR>}
<BR>
<P>
<A HREF="index.html">返回目录</A>
<P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -