国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

C語言庫函數(shù)(T類字母)

2019-11-17 05:42:57
字體:
供稿:網(wǎng)友
   
函數(shù)名: tan 
功  能: 正切函數(shù) 
用  法: double tan(double x); 
程序例: 

#include <stdio.h> 
#include <math.h> 

int main(void) 

   double result, x; 

   x = 0.5; 
   result = tan(x); 
      return 0; 

  
  
  

函數(shù)名: tanh 
功  能: 雙曲正切函數(shù) 
用  法: 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; 

  
  
  
  

函數(shù)名: tell 
功  能: 取文件指針的當(dāng)前位置 
用  法: 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; 

  
  
  
  

函數(shù)名: textattr 
功  能: 設(shè)置文本屬性 
用  法: 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; 

  
  
  

函數(shù)名: 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; 

  
  
  

函數(shù)名: 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; 

  
  
  

函數(shù)名: 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(TR
ipLEX_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; 

  
  
  

函數(shù)名: textmode 
功  能: 將屏幕設(shè)置成文本模式 
用  法: 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; 

  
  

函數(shù)名: 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; 

  
  

函數(shù)名: time 
功  能: 取一天的時(shí)間 
用  法: 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; 

  
  
  

函數(shù)名: tmpfile 
功  能: 以二進(jìn)制方式打開暫存文件 
用  法: 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; 

  
  
  

函數(shù)名: tmpnam 
功  能: 創(chuàng)建一個(gè)唯一的文件名 
用  法: char *tmpnam(char *sptr); 
程序例: 

#include <stdio.h> 

int main(void) 

   char name[13]; 

   tmpnam(name); 
   printf("Temporary name: %s/n", name); 
   return 0; 

  
  
  

函數(shù)名: tolower 
功  能: 把字符轉(zhuǎn)換成小寫字母 
用  法: 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; 

  
  

函數(shù)名: toupper 
功  能: 把字符轉(zhuǎn)換成大寫字母 
用  法: 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; 

  
  

函數(shù)名: tzset 
功  能: UNIX時(shí)間兼容函數(shù) 
用  法: 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; 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鲁甸县| 江北区| 织金县| 北辰区| 固始县| 韶山市| 鄢陵县| 西宁市| 大庆市| 黔西县| 六枝特区| 项城市| 三明市| 自贡市| 扎赉特旗| 饶平县| 阆中市| 鹤山市| 开化县| 枣强县| 呼图壁县| 互助| 诸城市| 阿荣旗| 大埔县| 岳普湖县| 宜城市| 淳化县| 通道| 新乐市| 嵊泗县| 沁源县| 朔州市| 察雅县| 陆良县| 教育| 资溪县| 白河县| 固原市| 余干县| 敦化市|