?? c.htm
字號:
<PRE>/* close the file */
close(handle);
}
else
{
printf("Error opening file\n");
}
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("The time was: %f\n", (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(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult(); </PRE>
<PRE>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 */
} </PRE>
<PRE>x = getmaxx() / 2;
y = getmaxy() / 2; </PRE>
<PRE>/* output a message */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, "Press a key to close the graphics system:"); </PRE>
<PRE>/* wait for a key */
getch(); </PRE>
<PRE>/* closes down the graphics system */
closegraph(); </PRE>
<PRE>printf("We're now back in text mode.\n");
printf("Press any key to halt:");
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("The function CLREOL clears all characters from the\r\n");
cprintf("cursor position to the end of the line within the\r\n");
cprintf("current text window, without moving the cursor.\r\n");
cprintf("Press any key to continue . . .");
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 < 20; i++)
cprintf("%d\r\n", i);
cprintf("\r\nPress any key to clear screen");
getch(); </PRE>
<PRE>clrscr();
cprintf("The screen has been cleared!");
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("The difference between the highest allocated block and\n");
printf("the top of the heap is: %lu bytes\n", (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("The cosine of %lf is %lf\n", 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("The hyperboic cosine of %lf is %lf\n", 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, &country_info);
printf("The currency symbol for the USA is: %s\n",
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("Hello world\r\n"); </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("This is within the window\r\n"); </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] = "0123456789"; </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("DUMMY.FIL", 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] = "0123456789"; </PRE>
<PRE>/* attempt to create a file that doesn't already exist */
handle = creatnew("DUMMY.FIL", 0); </PRE>
<PRE>if (handle == -1)
printf("DUMMY.FIL already exists.\n");
else
{
printf("DUMMY.FIL successfully created.\n");
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, "\\"); </PRE>
<PRE>/* create a unique file in the root directory */
handle = creattemp(pathname, 0); </PRE>
<PRE>printf("%s was the unique file created.\n", 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("Enter a string with no spaces:"); </PRE>
<PRE>/* read the input */
cscanf("%s", string); </PRE>
<PRE>/* display what was read */
cprintf("\r\nThe string entered is: %s", 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(&t);
printf("Today's date and time: %s\n", ctime(&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("Control-Break pressed. Program aborting ...\n");
return (ABORT);
} </PRE>
<PRE>int main(void)
{
ctrlbrk(c_break);
for(;;)
{
printf("Looping... Press to quit:\n");
}
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 + -