📄 fc.htm
字号:
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <alloc.h> </font>
<P><font color="#003399">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());
</font>
<P><font color="#003399"> return 0; <BR>
} <BR>
</font>
<P><font color="#003399">函数名: cos <BR>
功 能: 余弦函数 <BR>
用 法: double cos(double x); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <math.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
double result; <BR>
double x = 0.5; </font>
<P><font color="#003399"> result = cos(x); <BR>
printf("The cosine of %lf is %lf\n", x, result); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: cosh <BR>
功 能: 双曲余弦函数 <BR>
用 法: dluble cosh(double x); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <math.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
double result; <BR>
double x = 0.5; </font>
<P><font color="#003399"> result = cosh(x); <BR>
printf("The hyperboic cosine of %lf is %lf\n", x, result); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: country <BR>
功 能: 返回与国家有关的信息 <BR>
用 法: struct COUNTRY *country(int countrycode, struct country *country);
<BR>
程序例: </font>
<P><font color="#003399">#include <dos.h> <BR>
#include <stdio.h> </font>
<P><font color="#003399">#define USA 0 </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
struct COUNTRY country_info; </font>
<P><font color="#003399"> 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>
</font>
<P><font color="#003399">函数名: cprintf <BR>
功 能: 送格式化输出至屏幕 <BR>
用 法: int cprintf(const char *format[, argument, ...]); <BR>
程序例: </font>
<P><font color="#003399">#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
/* clear the screen */ <BR>
clrscr(); </font>
<P><font color="#003399"> /* create a text window */ <BR>
window(10, 10, 80, 25); </font>
<P><font color="#003399"> /* output some text in the window */ <BR>
cprintf("Hello world\r\n"); </font>
<P><font color="#003399"> /* wait for a key */ <BR>
getch(); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: cputs <BR>
功 能: 写字符到屏幕 <BR>
用 法: void cputs(const char *string); <BR>
程序例: </font>
<P><font color="#003399">#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
/* clear the screen */ <BR>
clrscr(); </font>
<P><font color="#003399"> /* create a text window */ <BR>
window(10, 10, 80, 25); </font>
<P><font color="#003399"> /* output some text in the window */ <BR>
cputs("This is within the window\r\n"); </font>
<P><font color="#003399"> /* wait for a key */ <BR>
getch(); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: _creat creat <BR>
功 能: 创建一个新文件或重写一个已存在的文件 <BR>
用 法: int creat (const char *filename, int permiss); <BR>
程序例: </font>
<P><font color="#003399">#include <sys\stat.h> <BR>
#include <string.h> <BR>
#include <fcntl.h> <BR>
#include <io.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int handle; <BR>
char buf[11] = "0123456789"; </font>
<P><font color="#003399"> /* change the default file mode from text
to binary */ <BR>
_fmode = O_BINARY; </font>
<P><font color="#003399"> /* create a binary file for reading and
writing */ <BR>
handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE); </font>
<P><font color="#003399"> /* write 10 bytes to the file */ <BR>
write(handle, buf, strlen(buf)); </font>
<P><font color="#003399"> /* close the file */ <BR>
close(handle); <BR>
return 0; <BR>
} <BR>
</font>
<P><font color="#003399">函数名: creatnew <BR>
功 能: 创建一个新文件 <BR>
用 法: int creatnew(const char *filename, int attrib); <BR>
程序例: </font>
<P><font color="#003399">#include <string.h> <BR>
#include <stdio.h> <BR>
#include <errno.h> <BR>
#include <dos.h> <BR>
#include <io.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int handle; <BR>
char buf[11] = "0123456789"; </font>
<P><font color="#003399"> /* attempt to create a file that doesn't
already exist */ <BR>
handle = creatnew("DUMMY.FIL", 0); </font>
<P><font color="#003399"> 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>
</font>
<P><font color="#003399">函数名: creattemp <BR>
功 能: 创建一个新文件或重写一个已存在的文件 <BR>
用 法: int creattemp(const char *filename, int attrib); <BR>
程序例: </font>
<P><font color="#003399">#include <string.h> <BR>
#include <stdio.h> <BR>
#include <io.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int handle; <BR>
char pathname[128]; </font>
<P><font color="#003399"> strcpy(pathname, "\\"); </font>
<P><font color="#003399"> /* create a unique file in the root directory
*/ <BR>
handle = creattemp(pathname, 0); </font>
<P><font color="#003399"> printf("%s was the unique file created.\n",
pathname); <BR>
close(handle); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: cscanf <BR>
功 能: 从控制台执行格式化输入 <BR>
用 法: int cscanf(char *format[,argument, ...]); <BR>
程序例: </font>
<P><font color="#003399">#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
char string[80]; </font>
<P><font color="#003399"> /* clear the screen */ <BR>
clrscr(); </font>
<P><font color="#003399"> /* Prompt the user for input */ <BR>
cprintf("Enter a string with no spaces:"); </font>
<P><font color="#003399"> /* read the input */ <BR>
cscanf("%s", string); </font>
<P><font color="#003399"> /* display what was read */ <BR>
cprintf("\r\nThe string entered is: %s", string); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: ctime <BR>
功 能: 把日期和时间转换为字符串 <BR>
用 法: char *ctime(const time_t *time); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <time.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
time_t t; </font>
<P><font color="#003399"> time(&t); <BR>
printf("Today's date and time: %s\n", ctime(&t)); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: ctrlbrk <BR>
功 能: 设置Ctrl-Break处理程序 <BR>
用 法: void ctrlbrk(*fptr)(void); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <dos.h> </font>
<P><font color="#003399">#define ABORT 0 </font>
<P><font color="#003399">int c_break(void) <BR>
{ <BR>
printf("Control-Break pressed. Program aborting ...\n");
<BR>
return (ABORT); <BR>
} </font>
<P><font color="#003399">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>
</font>
<P><font color="#003399">
<A HREF="cyyhsdq.htm">返回</A></font>
<P><font color="#003399"> </font>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -