📄 ft.htm
字号:
<HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <META NAME="Author" CONTENT="wdg"> <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]"> <TITLE>ft</TITLE></HEAD><BODY> <P>函数名: tan<BR>功 能: 正切函数<BR>用 法: double tan(double x);<BR>程序例:<P>#include <stdio.h><BR>#include <math.h><P>int main(void)<BR>{<BR> double result, x;<P> x = 0.5;<BR> result = tan(x);<BR> printf("The tan of %lf is %lf\n", x, result);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: tanh<BR>功 能: 双曲正切函数<BR>用 法: double tanh(double x);<BR>程序例:<P>#include <stdio.h><BR>#include <math.h><P>int main(void)<BR>{<BR> double result, x;<P> x = 0.5;<BR> result = tanh(x);<BR> printf("The hyperbolic tangent of %lf is %lf\n", x, result);<BR> return 0;<BR>}<BR> <BR> <BR> <BR> <P>函数名: tell<BR>功 能: 取文件指针的当前位置<BR>用 法: long tell(int handle);<BR>程序例:<P>#include <string.h><BR>#include <stdio.h><BR>#include <fcntl.h><BR>#include <io.h><P>int main(void)<BR>{<BR> int handle;<BR> char msg[] = "Hello world";<P> if ((handle = open("TEST.$$$", O_CREAT | O_TEXT | O_APPEND))== -1)<BR> {<BR> perror("Error:");<BR> return 1;<BR> }<BR> write(handle, msg, strlen(msg));<BR> printf("The file pointer is at byte %ld\n", tell(handle));<BR> close(handle);<BR> return 0;<BR>}<BR> <BR> <BR> <BR> <P>函数名: textattr<BR>功 能: 设置文本属性<BR>用 法: void textattr(int attribute);<BR>程序例:<P>#include <conio.h><P>int main(void)<BR>{<BR> int i;<P> clrscr();<BR> for (i=0; i<9; i++)<BR> {<BR> textattr(i + ((i+1) << 4));<BR> cprintf("This is a test\r\n");<BR> }<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: textbackground<BR>功 能: 选择新的文本背景颜色<BR>用 法: void textbackground(int color);<BR>程序例:<P>#include <conio.h><P>int main(void)<BR>{<BR> int i, j;<P> clrscr();<BR> for (i=0; i<9; i++)<BR> {<BR> for (j=0; j<80; j++)<BR> cprintf("C");<BR> cprintf("\r\n");<BR> textcolor(i+1);<BR> textbackground(i);<BR> }<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: textcolor<BR>功 能: 在文本模式中选择新的字符颜色<BR>用 法: void textcolor(int color);<BR>程序例:<BR>#include <conio.h><P>int main(void)<BR>{<BR> int i;<P> for (i=0; i<15; i++)<BR> {<BR> textcolor(i);<BR> cprintf("Foreground Color\r\n");<BR> }<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: textheight<BR>功 能: 返回以像素为单位的字符串高度<BR>用 法: int far textheight(char far *textstring);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int y = 0;<BR> int i;<BR> char msg[80];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> /* draw some text on the screen */<BR> for (i=1; i<11; i++)<BR> {<BR> /* select the text style, direction,and size */<BR> settextstyle(TRIPLEX_FONT, HORIZ_DIR,i);<P> /* create a message string */<BR> sprintf(msg, "Size: %d", i);<P> /* output the message */<BR> outtextxy(1, y, msg);<P> /* advance to the next text line */<BR> y += textheight(msg);<BR> }<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: textmode<BR>功 能: 将屏幕设置成文本模式<BR>用 法: void textmode(int mode);<BR>程序例:<P>#include <conio.h><P>int main(void)<BR>{<BR> textmode(BW40);<BR> cprintf("ABC");<BR> getch();<P> textmode(C40);<BR> cprintf("ABC");<BR> getch();<P> textmode(BW80);<BR> cprintf("ABC");<BR> getch();<P> textmode(C80);<BR> cprintf("ABC");<BR> getch();<P> textmode(MONO);<BR> cprintf("ABC");<BR> getch();<P> return 0;<BR>}<BR> <BR> <P>函数名: textwidth<BR>功 能: 返回以像素为单位的字符串宽度<BR>用 法: int far textwidth(char far *textstring);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int x = 0, y = 0;<BR> int i;<BR> char msg[80];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> y = getmaxy() / 2;<P> settextjustify(LEFT_TEXT, CENTER_TEXT);<BR> for (i=1; i<11; i++)<BR> {<BR> /* select the text style, direction,and size */<BR> settextstyle(TRIPLEX_FONT, HORIZ_DIR,i);<P> /* create a message string */<BR> sprintf(msg, "Size: %d", i);<P> /* output the message */<BR> outtextxy(x, y, msg);<P> /* advance to the end of the text */<BR> x += textwidth(msg);<BR> }<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: time<BR>功 能: 取一天的时间<BR>用 法: logn time(long *tloc);<BR>程序例:<P>#include <time.h><BR>#include <stdio.h><BR>#include <dos.h><P>int main(void)<BR>{<BR> time_t t;<P> t = time(NULL);<BR> printf("The number of seconds since January 1, 1970 is%ld",t);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: tmpfile<BR>功 能: 以二进制方式打开暂存文件<BR>用 法: FILE *tmpfile(void);<BR>程序例:<P>#include <stdio.h><BR>#include <process.h><P>int main(void)<BR>{<BR> FILE *tempfp;<P> tempfp = tmpfile();<BR> if (tempfp)<BR> printf("Temporary file created\n");<BR> else<BR> {<BR> printf("Unable to create temporary file\n");<BR> exit(1);<BR> }<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: tmpnam<BR>功 能: 创建一个唯一的文件名<BR>用 法: char *tmpnam(char *sptr);<BR>程序例:<P>#include <stdio.h><P>int main(void)<BR>{<BR> char name[13];<P> tmpnam(name);<BR> printf("Temporary name: %s\n", name);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: tolower<BR>功 能: 把字符转换成小写字母<BR>用 法: int tolower(int c);<BR>程序例:<P>#include <string.h><BR>#include <stdio.h><BR>#include <ctype.h><P>int main(void)<BR>{<BR> int length, i;<BR> char *string = "THIS IS A STRING";<P> length = strlen(string);<BR> for (i=0; i<length; i++)<BR> {<BR> string[i] = tolower(string[i]);<BR> }<BR> printf("%s\n",string);<P> return 0;<BR>}<BR> <BR> <P>函数名: toupper<BR>功 能: 把字符转换成大写字母<BR>用 法: int toupper(int c);<BR>程序例:<P>#include <string.h><BR>#include <stdio.h><BR>#include <ctype.h><P>int main(void)<BR>{<BR> int length, i;<BR> char *string = "this is a string";<P> length = strlen(string);<BR> for (i=0; i<length; i++)<BR> {<BR> string[i] = toupper(string[i]);<BR> }<P> printf("%s\n",string);<P> return 0;<BR>}<BR> <BR> <P>函数名: tzset<BR>功 能: UNIX时间兼容函数<BR>用 法: void tzset(void);<BR>程序例:<P>#include <time.h><BR>#include <stdlib.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> time_t td;<P> putenv("TZ=PST8PDT");<BR> tzset();<BR> time(&td);<BR> printf("Current time = %s\n", asctime(localtime(&td)));<BR> return 0;<BR>}<BR> <P> <A HREF="index.html">返回目录</A><P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -