⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fc.htm

📁 C函数速查。很有用的手册。相信会对大家的编程有用。
💻 HTM
📖 第 1 页 / 共 3 页
字号:
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;alloc.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; printf("The difference between the highest allocated block and\n"); 
  <BR>
  &nbsp;&nbsp; printf("the top of the heap is: %lu bytes\n", (unsigned long) coreleft()); 
  </font>
<P><font color="#003399">&nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: cos <BR>
  功&nbsp; 能: 余弦函数 <BR>
  用&nbsp; 法: double cos(double x); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;math.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; double result; <BR>
  &nbsp;&nbsp; double x = 0.5; </font>
<P><font color="#003399">&nbsp;&nbsp; result = cos(x); <BR>
  &nbsp;&nbsp; printf("The cosine of %lf is %lf\n", x, result); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: cosh <BR>
  功&nbsp; 能: 双曲余弦函数 <BR>
  用&nbsp; 法: dluble cosh(double x); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;math.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; double result; <BR>
  &nbsp;&nbsp; double x = 0.5; </font>
<P><font color="#003399">&nbsp;&nbsp; result = cosh(x); <BR>
  &nbsp;&nbsp; printf("The hyperboic cosine of %lf is %lf\n", x, result); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: country <BR>
  功&nbsp; 能: 返回与国家有关的信息 <BR>
  用&nbsp; 法: struct COUNTRY *country(int countrycode, struct country *country); 
  <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;dos.h> <BR>
  #include &lt;stdio.h> </font>
<P><font color="#003399">#define USA 0 </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; struct COUNTRY country_info; </font>
<P><font color="#003399">&nbsp;&nbsp; country(USA, &amp;country_info); <BR>
  &nbsp;&nbsp; printf("The currency symbol for the USA is: %s\n", <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; country_info.co_curr); 
  <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: cprintf <BR>
  功&nbsp; 能: 送格式化输出至屏幕 <BR>
  用&nbsp; 法: int cprintf(const char *format[, argument, ...]); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;conio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; /* clear the screen */ <BR>
  &nbsp;&nbsp; clrscr(); </font>
<P><font color="#003399">&nbsp;&nbsp; /* create a text window */ <BR>
  &nbsp;&nbsp; window(10, 10, 80, 25); </font>
<P><font color="#003399">&nbsp;&nbsp; /* output some text in the window */ <BR>
  &nbsp;&nbsp; cprintf("Hello world\r\n"); </font>
<P><font color="#003399">&nbsp;&nbsp; /* wait for a key */ <BR>
  &nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: cputs <BR>
  功&nbsp; 能: 写字符到屏幕 <BR>
  用&nbsp; 法: void cputs(const char *string); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;conio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; /* clear the screen */ <BR>
  &nbsp;&nbsp; clrscr(); </font>
<P><font color="#003399">&nbsp;&nbsp; /* create a text window */ <BR>
  &nbsp;&nbsp; window(10, 10, 80, 25); </font>
<P><font color="#003399">&nbsp;&nbsp; /* output some text in the window */ <BR>
  &nbsp;&nbsp; cputs("This is within the window\r\n"); </font>
<P><font color="#003399">&nbsp;&nbsp; /* wait for a key */ <BR>
  &nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: _creat&nbsp; creat <BR>
  功&nbsp; 能: 创建一个新文件或重写一个已存在的文件 <BR>
  用&nbsp; 法: int creat (const char *filename, int permiss); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;sys\stat.h> <BR>
  #include &lt;string.h> <BR>
  #include &lt;fcntl.h> <BR>
  #include &lt;io.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; int handle; <BR>
  &nbsp;&nbsp; char buf[11] = "0123456789"; </font>
<P><font color="#003399">&nbsp;&nbsp; /* change the default file mode from text 
  to binary */ <BR>
  &nbsp;&nbsp; _fmode = O_BINARY; </font>
<P><font color="#003399">&nbsp;&nbsp; /* create a binary file for reading and 
  writing */ <BR>
  &nbsp;&nbsp; handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE); </font>
<P><font color="#003399">&nbsp;&nbsp; /* write 10 bytes to the file */ <BR>
  &nbsp;&nbsp; write(handle, buf, strlen(buf)); </font>
<P><font color="#003399">&nbsp;&nbsp; /* close the file */ <BR>
  &nbsp;&nbsp; close(handle); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: creatnew <BR>
  功&nbsp; 能: 创建一个新文件 <BR>
  用&nbsp; 法: int creatnew(const char *filename, int attrib); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;string.h> <BR>
  #include &lt;stdio.h> <BR>
  #include &lt;errno.h> <BR>
  #include &lt;dos.h> <BR>
  #include &lt;io.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; int handle; <BR>
  &nbsp;&nbsp; char buf[11] = "0123456789"; </font>
<P><font color="#003399">&nbsp;&nbsp; /* attempt to create a file that doesn't 
  already exist */ <BR>
  &nbsp;&nbsp; handle = creatnew("DUMMY.FIL", 0); </font>
<P><font color="#003399">&nbsp;&nbsp; if (handle == -1) <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("DUMMY.FIL already exists.\n"); <BR>
  &nbsp;&nbsp; else <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("DUMMY.FIL successfully created.\n"); 
  <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(handle, buf, strlen(buf)); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close(handle); <BR>
  &nbsp;&nbsp; } <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: creattemp <BR>
  功&nbsp; 能: 创建一个新文件或重写一个已存在的文件 <BR>
  用&nbsp; 法: int creattemp(const char *filename, int attrib); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;string.h> <BR>
  #include &lt;stdio.h> <BR>
  #include &lt;io.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; int handle; <BR>
  &nbsp;&nbsp; char pathname[128]; </font>
<P><font color="#003399">&nbsp;&nbsp; strcpy(pathname, "\\"); </font>
<P><font color="#003399">&nbsp;&nbsp; /* create a unique file in the root directory 
  */ <BR>
  &nbsp;&nbsp; handle = creattemp(pathname, 0); </font>
<P><font color="#003399">&nbsp;&nbsp; printf("%s was the unique file created.\n", 
  pathname); <BR>
  &nbsp;&nbsp; close(handle); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: cscanf <BR>
  功&nbsp; 能: 从控制台执行格式化输入 <BR>
  用&nbsp; 法: int cscanf(char *format[,argument, ...]); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;conio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; char string[80]; </font>
<P><font color="#003399">&nbsp;&nbsp; /* clear the screen */ <BR>
  &nbsp;&nbsp; clrscr(); </font>
<P><font color="#003399">&nbsp;&nbsp; /* Prompt the user for input */ <BR>
  &nbsp;&nbsp; cprintf("Enter a string with no spaces:"); </font>
<P><font color="#003399">&nbsp;&nbsp; /* read the input */ <BR>
  &nbsp;&nbsp; cscanf("%s", string); </font>
<P><font color="#003399">&nbsp;&nbsp; /* display what was read */ <BR>
  &nbsp;&nbsp; cprintf("\r\nThe string entered is: %s", string); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: ctime <BR>
  功&nbsp; 能: 把日期和时间转换为字符串 <BR>
  用&nbsp; 法: char *ctime(const time_t *time); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;time.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; time_t t; </font>
<P><font color="#003399">&nbsp;&nbsp; time(&amp;t); <BR>
  &nbsp;&nbsp; printf("Today's date and time: %s\n", ctime(&amp;t)); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: ctrlbrk <BR>
  功&nbsp; 能: 设置Ctrl-Break处理程序 <BR>
  用&nbsp; 法: void ctrlbrk(*fptr)(void); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;dos.h> </font>
<P><font color="#003399">#define ABORT 0 </font>
<P><font color="#003399">int c_break(void) <BR>
  { <BR>
  &nbsp;&nbsp; printf("Control-Break pressed.&nbsp; Program aborting ...\n"); 
  <BR>
  &nbsp;&nbsp; return (ABORT); <BR>
  } </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; ctrlbrk(c_break); <BR>
  &nbsp;&nbsp; for(;;) <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Looping... Press &lt;Ctrl-Break> to quit:\n"); 
  <BR>
  &nbsp;&nbsp; } <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; </font>
<P><font color="#003399">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <A HREF="cyyhsdq.htm">返回</A></font>
<P><font color="#003399"> </font>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -