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

📄 c.htm

📁 C语言函数库,包含所有的C语言函数
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<PRE>/* close the file */ 
close(handle); 
} 
else 
{ 
printf(&quot;Error opening file\n&quot;); 
} 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">clock</font> 
功 能: 确定处理器时间 
用 法: clock_t clock(void); 
程序例: </PRE>
<PRE>#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
clock_t start, end; 
start = clock(); </PRE>
<PRE>delay(2000); </PRE>
<PRE>end = clock(); 
printf(&quot;The time was: %f\n&quot;, (end - start) / CLK_TCK); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">closegraph</font> 
功 能: 关闭图形系统 
用 法: void far closegraph(void); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int x, y; </PRE>
<PRE>/* initialize graphics mode */ 
initgraph(&amp;gdriver, &amp;gmode, &quot;&quot;); </PRE>
<PRE>/* read result of initialization */ 
errorcode = graphresult(); </PRE>
<PRE>if (errorcode != grOk) /* an error 
occurred */ 
{ 
printf(&quot;Graphics error: %s\n&quot;, grapherrormsg(errorcode)); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
exit(1); /* terminate with an error code */ 
} </PRE>
<PRE>x = getmaxx() / 2; 
y = getmaxy() / 2; </PRE>
<PRE>/* output a message */ 
settextjustify(CENTER_TEXT, CENTER_TEXT); 
outtextxy(x, y, &quot;Press a key to close the graphics system:&quot;); </PRE>
<PRE>/* wait for a key */ 
getch(); </PRE>
<PRE>/* closes down the graphics system */ 
closegraph(); </PRE>
<PRE>printf(&quot;We're now back in text mode.\n&quot;); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">clreol </font>
功 能: 在文本窗口中清除字符到行末 
用 法: void clreol(void); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) </PRE>
<PRE>{ 
clrscr(); 
cprintf(&quot;The function CLREOL clears all characters from the\r\n&quot;); 
cprintf(&quot;cursor position to the end of the line within the\r\n&quot;); 
cprintf(&quot;current text window, without moving the cursor.\r\n&quot;); 
cprintf(&quot;Press any key to continue . . .&quot;); 
gotoxy(14, 4); 
getch(); </PRE>
<PRE>clreol(); 
getch(); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> clrscr </font>
功 能: 清除文本模式窗口 
用 法: void clrscr(void); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) 
{ 
int i; </PRE>
<PRE>clrscr(); 
for (i = 0; i &lt; 20; i++) 
cprintf(&quot;%d\r\n&quot;, i); 
cprintf(&quot;\r\nPress any key to clear screen&quot;); 
getch(); </PRE>
<PRE>clrscr(); 
cprintf(&quot;The screen has been cleared!&quot;); 
getch(); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">coreleft</font> 
功 能: 返回未使用内存的大小 
用 法: unsigned coreleft(void); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
printf(&quot;The difference between the highest allocated block and\n&quot;); 
printf(&quot;the top of the heap is: %lu bytes\n&quot;, (unsigned long) coreleft()); </PRE>
<PRE>return 0; 
} 
</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> cos </font>
功 能: 余弦函数 
用 法: double cos(double x); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
double result; 
double x = 0.5; </PRE>
<PRE>result = cos(x); 
printf(&quot;The cosine of %lf is %lf\n&quot;, x, result); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> cosh </font>
功 能: 双曲余弦函数 
用 法: dluble cosh(double x); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
double result; 
double x = 0.5; </PRE>
<PRE>result = cosh(x); 
printf(&quot;The hyperboic cosine of %lf is %lf\n&quot;, x, result); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">country </font>
功 能: 返回与国家有关的信息 
用 法: struct COUNTRY *country(int countrycode, struct country *country); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>#define USA 0 </PRE>
<PRE>int main(void) 
{ 
struct COUNTRY country_info; </PRE>
<PRE>country(USA, &amp;country_info); 
printf(&quot;The currency symbol for the USA is: %s\n&quot;, 
country_info.co_curr); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">cprintf </font>
功 能: 送格式化输出至屏幕 
用 法: int cprintf(const char *format[, argument, ...]); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) 
{ 
/* clear the screen */ 
clrscr(); </PRE>
<PRE>/* create a text window */ 
window(10, 10, 80, 25); </PRE>
<PRE>/* output some text in the window */ 
cprintf(&quot;Hello world\r\n&quot;); </PRE>
<PRE>/* wait for a key */ 
getch(); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">cputs </font>
功 能: 写字符到屏幕 
用 法: void cputs(const char *string); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) 
{ 
/* clear the screen */ 
clrscr(); </PRE>
<PRE>/* create a text window */ 
window(10, 10, 80, 25); </PRE>
<PRE>/* output some text in the window */ 
cputs(&quot;This is within the window\r\n&quot;); </PRE>
<PRE>/* wait for a key */ 
getch(); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">_creat </font>
功 能: 创建一个新文件或重写一个已存在的文件 
用 法: int creat (const char *filename, int permiss); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
int handle; 
char buf[11] = &quot;0123456789&quot;; </PRE>
<PRE>/* change the default file mode from text to binary */ 
_fmode = O_BINARY; </PRE>
<PRE>/* create a binary file for reading and writing */ 
handle = creat(&quot;DUMMY.FIL&quot;, S_IREAD | S_IWRITE); </PRE>
<PRE>/* write 10 bytes to the file */ 
write(handle, buf, strlen(buf)); </PRE>
<PRE>/* close the file */ 
close(handle); 
return 0; 
} 
</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> creatnew</font> 
功 能: 创建一个新文件 
用 法: int creatnew(const char *filename, int attrib); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
int handle; 
char buf[11] = &quot;0123456789&quot;; </PRE>
<PRE>/* attempt to create a file that doesn't already exist */ 
handle = creatnew(&quot;DUMMY.FIL&quot;, 0); </PRE>
<PRE>if (handle == -1) 
printf(&quot;DUMMY.FIL already exists.\n&quot;); 
else 
{ 
printf(&quot;DUMMY.FIL successfully created.\n&quot;); 
write(handle, buf, strlen(buf)); 
close(handle); 
} 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">creattemp</font>
功 能: 创建一个新文件或重写一个已存在的文件 
用 法: int creattemp(const char *filename, int attrib); 
程序例: </PRE>
<PRE>#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
int handle; 
char pathname[128]; </PRE>
<PRE>strcpy(pathname, &quot;\\&quot;); </PRE>
<PRE>/* create a unique file in the root directory */ 
handle = creattemp(pathname, 0); </PRE>
<PRE>printf(&quot;%s was the unique file created.\n&quot;, pathname); 
close(handle); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">cscanf</font> 
功 能: 从控制台执行格式化输入 
用 法: int cscanf(char *format[,argument, ...]); 
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void) 
{ 
char string[80]; </PRE>
<PRE>/* clear the screen */ 
clrscr(); </PRE>
<PRE>/* Prompt the user for input */ 
cprintf(&quot;Enter a string with no spaces:&quot;); </PRE>
<PRE>/* read the input */ 
cscanf(&quot;%s&quot;, string); </PRE>
<PRE>/* display what was read */ 
cprintf(&quot;\r\nThe string entered is: %s&quot;, string); 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">ctime</font> 
功 能: 把日期和时间转换为字符串 
用 法: char *ctime(const time_t *time); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
time_t t; </PRE>
<PRE>time(&amp;t); 
printf(&quot;Today's date and time: %s\n&quot;, ctime(&amp;t)); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> ctrlbrk </font>
功 能: 设置Ctrl-Break处理程序 
用 法: void ctrlbrk(*fptr)(void); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>#define ABORT 0 </PRE>
<PRE>int c_break(void) 
{ 
printf(&quot;Control-Break pressed. Program aborting ...\n&quot;); 
return (ABORT); 
} </PRE>
<PRE>int main(void) 
{ 
ctrlbrk(c_break); 
for(;;) 
{ 
printf(&quot;Looping... Press to quit:\n&quot;); 
} 
return 0; 
} </PRE>
<pre> </pre>

<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>

<pre></pre>
<pre> </pre>
<pre>资料收集:beck Copyright 2004 张求熙, All Rights Reserved</pre>
<pre><a href="mailto:Email:qiuxi1984@126.com">Email:qiuxi1984@126.com</a>     QQ:35540948 </pre>

⌨️ 快捷键说明

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