函数名: tan
功  能: 正切函数
用  法: double tan(double x);
程序例:
#include <stdio.h>
#include <math.h>
int main(void)
{
double result, x;
x = 0.5;
result = tan(x);
printf("The tan of %lf is %lf\n", x, result);
return 0;
}
函数名: tanh
功  能: 双曲正切函数
用  法: double tanh(double x);
程序例:
#include <stdio.h>
#include <math.h>
int main(void)
{
double result, x;
x = 0.5;
result = tanh(x);
printf("The hyperbolic tangent of %lf is %lf\n", x, result);
return 0;
}
函数名: tell
功  能: 取文件指针的当前位置
用  法: long tell(int handle);
程序例:
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(void)
{
int handle;
char msg[] = "Hello world";
if ((handle = open("TEST.$$$", O_CREAT | O_TEXT | O_APPEND)) == -1)
{
perror("Error:");
return 1;
}
write(handle, msg, strlen(msg));
printf("The file pointer is at byte %ld\n", tell(handle));
close(handle);
return 0;
}
函数名: textattr
功  能: 设置文本属性
用  法: void textattr(int attribute);
程序例:
#include <conio.h>
int main(void)
{
int i;
clrscr();
for (i=0; i<9; i++)
{
textattr(i + ((i+1) << 4));
cprintf("This is a test\r\n");
}
return 0;
}
函数名: textbackground
功  能: 选择新的文本背景颜色
用  法: void textbackground(int color);
程序例:
#include <conio.h>
int main(void)
{
int i, j;
clrscr();
for (i=0; i<9; i++)
{
for (j=0; j<80; j++)
cprintf("C");
cprintf("\r\n");
textcolor(i+1);
textbackground(i);
}
return 0;
}
函数名: textcolor
功  能: 在文本模式中选择新的字符颜色
用  法: void textcolor(int color);
程序例:
#include <conio.h>
int main(void)
{
int i;
for (i=0; i<15; i++)
{
textcolor(i);
cprintf("Foreground Color\r\n");
}
return 0;
}
函数名: textheight
功  能: 返回以像素为单位的字符串高度
用  法: int far textheight(char far *textstring);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int y = 0;
int i;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* 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 */
}
/* draw some text on the screen */
for (i=1; i<11; i++)
{
/* select the text style, direction, and size */
settextstyle(TRIPLEX_FONT, HORIZ_DIR, i);
/* create a message string */
sprintf(msg, "Size: %d", i);
/* output the message */
outtextxy(1, y, msg);
/* advance to the next text line */
y += textheight(msg);
}
/* clean up */
getch();
closegraph();
return 0;
}
函数名: textmode
功  能: 将屏幕设置成文本模式
用  法: void textmode(int mode);
程序例:
#include <conio.h>
int main(void)
{
textmode(BW40);
cprintf("ABC");
getch();
textmode(C40);
cprintf("ABC");
getch();
textmode(BW80);
cprintf("ABC");
getch();
textmode(C80);
cprintf("ABC");
getch();
textmode(MONO);
cprintf("ABC");
getch();
return 0;
}
函数名: textwidth
功  能: 返回以像素为单位的字符串宽度
用  法: int far textwidth(char far *textstring);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int x = 0, y = 0;
int i;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* 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 */
}
y = getmaxy() / 2;
settextjustify(LEFT_TEXT, CENTER_TEXT);
for (i=1; i<11; i++)
{
/* select the text style, direction, and size */
settextstyle(TRIPLEX_FONT, HORIZ_DIR, i);
/* create a message string */
sprintf(msg, "Size: %d", i);
/* output the message */
outtextxy(x, y, msg);
/* advance to the end of the text */
x += textwidth(msg);
}
/* clean up */
getch();
closegraph();
return 0;
}
函数名: time
功  能: 取一天的时间
用  法: logn time(long *tloc);
程序例:
#include <time.h>
#include <stdio.h>
#include <dos.h>
int main(void)
{
time_t t;
t = time(NULL);
printf("The number of seconds since January 1, 1970 is %ld",t);
return 0;
}
函数名: tmpfile
功  能: 以二进制方式打开暂存文件
用  法: FILE *tmpfile(void);
程序例:
#include <stdio.h>
#include <process.h>
int main(void)
{
FILE *tempfp;
tempfp = tmpfile();
if (tempfp)
printf("Temporary file created\n");
else
{
printf("Unable to create temporary file\n");
exit(1);
}
return 0;
}
函数名: tmpnam
功  能: 创建一个唯一的文件名
用  法: char *tmpnam(char *sptr);
程序例:
#include <stdio.h>
int main(void)
{
char name[13];
tmpnam(name);
printf("Temporary name: %s\n", name);
return 0;
}
函数名: tolower
功  能: 把字符转换成小写字母
用  法: int tolower(int c);
程序例:
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int length, i;
char *string = "THIS IS A STRING";
length = strlen(string);
for (i=0; i<length; i++)
{
string[i] = tolower(string[i]);
}
printf("%s\n",string);
return 0;
}
函数名: toupper
功  能: 把字符转换成大写字母
用  法: int toupper(int c);
程序例:
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int length, i;
char *string = "this is a string";
length = strlen(string);
for (i=0; i<length; i++)
{
string[i] = toupper(string[i]);
}
printf("%s\n",string);
return 0;
}
函数名: tzset
功  能: UNIX时间兼容函数
用  法: void tzset(void);
程序例:
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
time_t td;
putenv("TZ=PST8PDT");
tzset();
time(&td);
printf("Current time = %s\n", asctime(localtime(&td)));
return 0;
}

C语言函数集(十八)相关推荐

  1. Python的内置函数(四十八)、setattr()函数

    参考 Python的内置函数(四十八).setattr()函数 - 云+社区 - 腾讯云 描述 setattr() 函数对应函数 getattr(),用于设置属性值,该属性不一定是存在的. 语法 se ...

  2. C语言试题六十八之请编写函数实现亲密数

    1. 题目 编写函数:求一个整数范围数字以内的全部亲密数. 亲密数:如果整数A的全部因子(包括1,不包括A本身)之和等于B:且整数B的全部因子(包括1,不包括B本身)之和等于A,则将整数A和B称为亲密 ...

  3. C语言试题五十八之请编写函数fun,:计算并输出下列多项式的值(sn=1+1/1!+1/2!+1/3!+1/4!+…+1/n! )

    1. 题目 请编写函数fun,其功能时:计算并输出下列多项式的值 sn=1+1/1!+1/2!+1/3!+1/4!+-+1/n! 2 .温馨提示 C语言试题汇总里可用于计算机二级C语言笔试.机试.研究 ...

  4. C语言试题四十八之该函数可以统计一个长度为2的字符串在另一个字符串中出现的次数。

    1. 题目 请编写一个函数function,它的功能是:该函数可以统计一个长度为2的字符串在另一个字符串中出现的次数. 2 .温馨提示 C语言试题汇总里可用于计算机二级C语言笔试.机试.研究生复试中C ...

  5. C语言试题二十八之编写函数function功能是:从字符中删除指定的字符,同一字母的大、小写按不同字符处理。

    1. 题目 编写函数function,该函数的功能是:从字符中删除指定的字符,同一字母的大.小写按不同字符处理. 2 .温馨提示 C试题汇总里可用于计算机二级C语言笔试.机试.研究生复试中C程序设计科 ...

  6. C语言函数集(二十)

    函数名: vfprintf 功 能: 送格式化输出到一流中 用 法: int vfprintf(FILE *stream, char *format, va_list param); 程序例: #in ...

  7. C语言函数集(十六)

    函数名: raise 功 能: 向正在执行的程序发送一个信号 用 法: int raise(int sig); 程序例: #include <signal.h> int main(void ...

  8. C语言函数集(十五)

    函数名: qsort 功 能: 使用快速排序例程进行排序 用 法: void qsort(void *base, int nelem, int width, int (*fcmp)()); 程序例: ...

  9. C语言函数集(十四)

    函数名: parsfnm 功 能: 分析文件名 用 法: char *parsfnm (char *cmdline, struct fcb *fcbptr, int option); 程序例: #in ...

最新文章

  1. 裴健等9名华人当选加拿大皇家学会院士
  2. 开发日记-20190506 关键词 汇编语言(五)Hello World!
  3. centos7 安装 mysql5.7
  4. 配置MySQL以进行ADF开发
  5. java lambda 实现_Java 8 Lambda实现原理分析
  6. mysql用户授权开发者_Mysql添加用户与授权
  7. 列表应用(导航菜单)
  8. APP引导页UI设计素材模板|轻松留下完美的第一印象
  9. Java基础 main 参数String[] args的用法
  10. BayaiM__MySQL错误对照表
  11. Python安装Pytorch教程(图文详解)
  12. litepal更好的操作sqlite3,配置与基本操作
  13. 数字图像处理总复习讲义
  14. 调用百度图像识别api处理网络图片(文字识别)
  15. Base64编码详解与URL安全的Base64编码
  16. 无线网卡安装后显示无服务器,USB无线网卡安装后连接图标不显示怎么办【解决方法】...
  17. systemd服务详解
  18. win10 系统识别不了移动硬盘
  19. less/sass中属性选择器使用方法
  20. 传奇3服务器配置文件,服务器技术交流_GowLom2战神引擎GameServer配置文件说明_-921根据地_只做有质量的游戏 - Powered by Discuz!...

热门文章

  1. web接口响应时间标准_从零搭建Web应用(二)
  2. oracle 一致性读数量,ORACLE 一致性读原理记录
  3. python在列表末尾删除一个_从链接列表的尾部移除(Python)
  4. class不生效 weblogic_weblogic下更改jsp不生效的解决办法
  5. 随行付微服务测试之静态代码扫描
  6. servlet的的生命周期和使用
  7. 利用MAVEN打包可运行jar包,包括依赖的第三方包
  8. shell学习笔记 (2)
  9. ----移动端移动端调试神器vConsole----
  10. 英文题,我恨你啊..