?? c.htm
字號:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body bgcolor="#00FFFF" text="#000080">
<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>函數(shù)大全(c開頭)
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">cabs</font>
功 能: 計算復(fù)數(shù)的絕對值
用 法: double cabs(struct complex z);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>int main(void)
{
struct complex z;
double val; </PRE>
<PRE>z.x = 2.0;
z.y = 1.0;
val = cabs(z); </PRE>
<PRE>printf("The absolute value of %.2lfi %.2lfj is %.2lf", z.x, z.y, val);
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">calloc </font>
功 能: 分配主存儲器
用 法: void *calloc(size_t nelem, size_t elsize);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>int main(void)
{
char *str = NULL; </PRE>
<PRE>/* allocate memory for string */
str = calloc(10, sizeof(char)); </PRE>
<PRE>/* copy "Hello" into string */
strcpy(str, "Hello"); </PRE>
<PRE>/* display string */
printf("String is %s\n", str); </PRE>
<PRE>/* free memory */
free(str); </PRE>
<PRE>return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">ceil </font>
功 能: 向上舍入
用 法: double ceil(double x);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>int main(void)
{
double number = 123.54;
double down, up; </PRE>
<PRE>down = floor(number);
up = ceil(number); </PRE>
<PRE>printf("original number %5.2lf\n", number);
printf("number rounded down %5.2lf\n", down);
printf("number rounded up %5.2lf\n", up); </PRE>
<PRE>return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">cgets </font>
功 能: 從控制臺讀字符串
用 法: char *cgets(char *str);
程序例: </PRE>
<PRE>#include
#include </PRE>
<PRE>int main(void)
{
char buffer[83];
char *p; </PRE>
<PRE>/* There's space for 80 characters plus the NULL terminator */
buffer[0] = 81; </PRE>
<PRE>printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer); </PRE>
<PRE>/* Leave room for 5 characters plus the NULL terminator */
buffer[0] = 6; </PRE>
<PRE>printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">chdir </font>
功 能: 改變工作目錄
用 法: int chdir(const char *path);
程序例: </PRE>
<PRE>#include
#include
#include </PRE>
<PRE>char old_dir[MAXDIR];
char new_dir[MAXDIR]; </PRE>
<PRE>int main(void)
{
if (getcurdir(0, old_dir))
{
perror("getcurdir()");
exit(1);
}
printf("Current directory is: \\%s\n", old_dir); </PRE>
<PRE>if (chdir("\\"))
{
perror("chdir()");
exit(1);
} </PRE>
<PRE>if (getcurdir(0, new_dir))
{
perror("getcurdir()");
exit(1);
}
printf("Current directory is now: \\%s\n", new_dir); </PRE>
<PRE>printf("\nChanging back to orignal directory: \\%s\n", old_dir);
if (chdir(old_dir))
{
perror("chdir()");
exit(1);
} </PRE>
<PRE>return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">_chmod</font>
功 能: 改變文件的訪問方式
用 法: int chmod(const char *filename, int permiss);
程序例: </PRE>
<PRE>#include
#include
#include </PRE>
<PRE>void make_read_only(char *filename); </PRE>
<PRE>int main(void)
{
make_read_only("NOTEXIST.FIL");
make_read_only("MYFILE.FIL");
return 0;
} </PRE>
<PRE>void make_read_only(char *filename)
{
int stat; </PRE>
<PRE>stat = chmod(filename, S_IREAD);
if (stat)
printf("Couldn't make %s read-only\n", filename);
else
printf("Made %s read-only\n", filename);
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">chsize </font>
功 能: 改變文件大小
用 法: int chsize(int handle, long size);
程序例: </PRE>
<PRE>#include
#include
#include </PRE>
<PRE>int main(void)
{
int handle;
char buf[11] = "0123456789"; </PRE>
<PRE>/* create text file containing 10 bytes */
handle = open("DUMMY.FIL", O_CREAT);
write(handle, buf, strlen(buf)); </PRE>
<PRE>/* truncate the file to 5 bytes in size */
chsize(handle, 5); </PRE>
<PRE>/* close the file */
close(handle);
return 0;
}
</PRE>
<PRE>函數(shù)名:<font size="5" color="#FF0000"> circle </font>
功 能: 在給定半徑以(x, y)為圓心畫圓
用 法: void far circle(int x, int y, int radius);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult();
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>midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor()); </PRE>
<PRE>/* draw the circle */
circle(midx, midy, radius); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">cleardevice </font>
功 能: 清除圖形屏幕
用 法: void far cleardevice(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult();
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>midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor()); </PRE>
<PRE>/* for centering screen messages */
settextjustify(CENTER_TEXT, CENTER_TEXT); </PRE>
<PRE>/* output a message to the screen */
outtextxy(midx, midy, "press any key to clear the screen:"); </PRE>
<PRE>/* wait for a key */
getch(); </PRE>
<PRE>/* clear the screen */
cleardevice(); </PRE>
<PRE>/* output another message */
outtextxy(midx, midy, "press any key to quit:"); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">clearerr</font>
功 能: 復(fù)位錯誤標(biāo)志
用 法:void clearerr(FILE *stream);
程序例: </PRE>
<PRE>#include </PRE>
<PRE>int main(void)
{
FILE *fp;
char ch; </PRE>
<PRE>/* open a file for writing */
fp = fopen("DUMMY.FIL", "w"); </PRE>
<PRE>/* force an error condition by attempting to read */
ch = fgetc(fp);
printf("%c\n",ch); </PRE>
<PRE>if (ferror(fp))
{
/* display an error message */
printf("Error reading from DUMMY.FIL\n"); </PRE>
<PRE>/* reset the error and EOF indicators */
clearerr(fp);
} </PRE>
<PRE>fclose(fp);
return 0;
}
</PRE>
<PRE>函數(shù)名: <font size="5" color="#FF0000">clearviewport</font>
功 能: 清除圖形視區(qū)
用 法: void far clearviewport(void);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>#define CLIP_ON 1 /* activates clipping in viewport */ </PRE>
<PRE>int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int ht; </PRE>
<PRE>/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); </PRE>
<PRE>/* read result of initialization */
errorcode = graphresult();
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>setcolor(getmaxcolor());
ht = textheight("W"); </PRE>
<PRE>/* message in default full-screen viewport */
outtextxy(0, 0, "* <-- (0, 0) in default viewport"); </PRE>
<PRE>/* create a smaller viewport */
setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON); </PRE>
<PRE>/* display some messages */
outtextxy(0, 0, "* <-- (0, 0) in smaller viewport");
outtextxy(0, 2*ht, "Press any key to clear viewport:"); </PRE>
<PRE>/* wait for a key */
getch(); </PRE>
<PRE>/* clear the viewport */
clearviewport(); </PRE>
<PRE>/* output another message */
outtextxy(0, 0, "Press any key to quit:"); </PRE>
<PRE>/* clean up */
getch();
closegraph();
return 0;
}
</PRE>
<PRE>函數(shù)名: _<font size="5" color="#FF0000">close </font>
功 能: 關(guān)閉文件句柄
用 法: int close(int handle);
程序例: </PRE>
<PRE>#include
#include
#include
#include </PRE>
<PRE>main()
{
int handle;
char buf[11] = "0123456789"; </PRE>
<PRE>/* create a file containing 10 bytes */
handle = open("NEW.FIL", O_CREAT);
if (handle > -1)
{
write(handle, buf, strlen(buf)); </PRE>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -