📄 t.htm
字号:
<td align=center><table border="0" width="700" cellspacing="0" cellpadding="0" align=center><tr><td valign=top><font color=#cccccc>
<br>函数名: tan
<br>功 能: 正切函数
<br>用 法: double tan(double x);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <math.h>
<br>
<br>int main(void)
<br>{
<br> double result, x;
<br>
<br> 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>
<br>
<br>函数名: tanh
<br>功 能: 双曲正切函数
<br>用 法: double tanh(double x);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <math.h>
<br>
<br>int main(void)
<br>{
<br> double result, x;
<br>
<br> 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>
<br>
<br>函数名: tell
<br>功 能: 取文件指针的当前位置
<br>用 法: long tell(int handle);
<br>程序例:
<br>
<br>#include <string.h>
<br>#include <stdio.h>
<br>#include <fcntl.h>
<br>#include <io.h>
<br>
<br>int main(void)
<br>{
<br> int handle;
<br> char msg[] = "Hello world";
<br>
<br> 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>
<br>
<br>函数名: textattr
<br>功 能: 设置文本属性
<br>用 法: void textattr(int attribute);
<br>程序例:
<br>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> int i;
<br>
<br> clrscr();
<br> for (i=0; i<9; i++)
<br> {
<br> textattr(i + ((i+1) << 4));
<br> cprintf("This is a test\r\n");
<br> }
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: textbackground
<br>功 能: 选择新的文本背景颜色
<br>用 法: void textbackground(int color);
<br>程序例:
<br>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> int i, j;
<br>
<br> 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> }
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: textcolor
<br>功 能: 在文本模式中选择新的字符颜色
<br>用 法: void textcolor(int color);
<br>程序例:
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> int i;
<br>
<br> for (i=0; i<15; i++)
<br> {
<br> textcolor(i);
<br> cprintf("Foreground Color\r\n");
<br> }
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: textheight
<br>功 能: 返回以像素为单位的字符串高度
<br>用 法: int far textheight(char far *textstring);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>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];
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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 error code */
<br> }
<br>
<br> /* 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);
<br>
<br> /* create a message string */
<br> sprintf(msg, "Size: %d", i);
<br>
<br> /* output the message */
<br> outtextxy(1, y, msg);
<br>
<br> /* advance to the next text line */
<br> y += textheight(msg);
<br> }
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: textmode
<br>功 能: 将屏幕设置成文本模式
<br>用 法: void textmode(int mode);
<br>程序例:
<br>
<br>#include <conio.h>
<br>
<br>int main(void)
<br>{
<br> textmode(BW40);
<br> cprintf("ABC");
<br> getch();
<br>
<br> textmode(C40);
<br> cprintf("ABC");
<br> getch();
<br>
<br> textmode(BW80);
<br> cprintf("ABC");
<br> getch();
<br>
<br> textmode(C80);
<br> cprintf("ABC");
<br> getch();
<br>
<br> textmode(MONO);
<br> cprintf("ABC");
<br> getch();
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: textwidth
<br>功 能: 返回以像素为单位的字符串宽度
<br>用 法: int far textwidth(char far *textstring);
<br>程序例:
<br>
<br>#include <graphics.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>#include <conio.h>
<br>
<br>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];
<br>
<br> /* initialize graphics and local variables */
<br> initgraph(&gdriver, &gmode, "");
<br>
<br> /* 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 error code */
<br> }
<br>
<br> y = getmaxy() / 2;
<br>
<br> 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);
<br>
<br> /* create a message string */
<br> sprintf(msg, "Size: %d", i);
<br>
<br> /* output the message */
<br> outtextxy(x, y, msg);
<br>
<br> /* advance to the end of the text */
<br> x += textwidth(msg);
<br> }
<br>
<br> /* clean up */
<br> getch();
<br> closegraph();
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: time
<br>功 能: 取一天的时间
<br>用 法: logn time(long *tloc);
<br>程序例:
<br>
<br>#include <time.h>
<br>#include <stdio.h>
<br>#include <dos.h>
<br>
<br>int main(void)
<br>{
<br> time_t t;
<br>
<br> t = time(NULL);
<br> printf("The number of seconds since January 1, 1970 is %ld",t);
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: tmpfile
<br>功 能: 以二进制方式打开暂存文件
<br>用 法: FILE *tmpfile(void);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>#include <process.h>
<br>
<br>int main(void)
<br>{
<br> FILE *tempfp;
<br>
<br> 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> }
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: tmpnam
<br>功 能: 创建一个唯一的文件名
<br>用 法: char *tmpnam(char *sptr);
<br>程序例:
<br>
<br>#include <stdio.h>
<br>
<br>int main(void)
<br>{
<br> char name[13];
<br>
<br> tmpnam(name);
<br> printf("Temporary name: %s\n", name);
<br> return 0;
<br>}
<br>
<br>
<br>
<br>
<br>函数名: tolower
<br>功 能: 把字符转换成小写字母
<br>用 法: int tolower(int c);
<br>程序例:
<br>
<br>#include <string.h>
<br>#include <stdio.h>
<br>#include <ctype.h>
<br>
<br>int main(void)
<br>{
<br> int length, i;
<br> char *string = "THIS IS A STRING";
<br>
<br> length = strlen(string);
<br> for (i=0; i<length; i++)
<br> {
<br> string[i] = tolower(string[i]);
<br> }
<br> printf("%s\n",string);
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: toupper
<br>功 能: 把字符转换成大写字母
<br>用 法: int toupper(int c);
<br>程序例:
<br>
<br>#include <string.h>
<br>#include <stdio.h>
<br>#include <ctype.h>
<br>
<br>int main(void)
<br>{
<br> int length, i;
<br> char *string = "this is a string";
<br>
<br> length = strlen(string);
<br> for (i=0; i<length; i++)
<br> {
<br> string[i] = toupper(string[i]);
<br> }
<br>
<br> printf("%s\n",string);
<br>
<br> return 0;
<br>}
<br>
<br>
<br>
<br>函数名: tzset
<br>功 能: UNIX时间兼容函数
<br>用 法: void tzset(void);
<br>程序例:
<br>
<br>#include <time.h>
<br>#include <stdlib.h>
<br>#include <stdio.h>
<br>
<br>int main(void)
<br>{
<br> time_t td;
<br>
<br> putenv("TZ=PST8PDT");
<br> tzset();
<br> time(&td);
<br> printf("Current time = %s\n", asctime(localtime(&td)));
<br> return 0;
<br>}
<br>(<a href=http://www.fanqiang.com>http://www.fanqiang.com</a>)</font> 进入【<a href=http://www.chinaunix.net>UNIX论坛</a>】</td></tr><tr><td><hr></td></tr><tr><td><b>相关文章</b> </td></tr><tr><td><a href=/a4/b2/20011027/1305001515.html>C语言库函数(W类字母)</a> <small>(2001-10-27 13:05:00)</small></font><br><a href=/a4/b2/20011027/0905001514.html>C语言库函数(V类字母)</a> <small>(2001-10-27 09:05:00)</small></font><br><a href=/a4/b2/20011027/0805011513.html>C语言库函数(U类字母)</a> <small>(2001-10-27 08:05:01)</small></font><br><a href=/a4/b2/20011027/0705001512.html>C语言库函数(T类字母)</a> <small>(2001-10-27 07:05:00)</small></font><br><a href=/a4/b2/20011026/0900001511.html>C语言库函数(S类字母) - 3</a> <small>(2001-10-26 09:00:00)</small></font><br><a href=/a4/b2/20011026/0800011510.html>C语言库函数(S类字母) - 2</a> <small>(2001-10-26 08:00:01)</small></font><br><a href=/a4/b2/20011026/0700001509.html>C语言库函数(S类字母) - 1</a> <small>(2001-10-26 07:00:00)</small></font><br><a href=/a4/b2/20011025/0900011508.html>C语言库函数(R类字母)</a> <small>(2001-10-25 09:00:01)</small></font><br><a href=/a4/b2/20011025/0800031507.html>C语言库函数(Q类字母)</a> <small>(2001-10-25 08:00:03)</small></font><br><a href=/a4/b2/20011025/0700011506.html>C语言库函数(P类字母)</a> <small>(2001-10-25 07:00:01)</small></font><br></td></tr><tr><tr><td><br>===<a href=/cgi-bin/find.cgi?key=C语言库函数>更多相关</a>===</td></tr><td> </td></tr></table></td></tr><tr> <td width="100%" height="2" colspan="5" bgcolor="#D09F0D"><img src="/images/c.gif" width=1 height=1></td> </tr><tr> <td width="100%" height="40" colspan="5" valign=top><p align="center"><font color=#ffffff>★ 樊强制作 欢迎分享 ★ </font></p></td> </tr></table></center></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -