C language library function (T class letters)

xiaoxiao2021-03-06  41

Function name: TAN

Function: 正 正 切

Usage: Double Tan (Double X);

Example:

#include

#include

Int main (void)

{

Double Result, X;

X = 0.5;

Result = tan (x);

Printf ("Tan of% LF IS% LF / N", X, Result);

Return 0;

}

Function name: Tanh

Function: Double Tag Positive Split Function

Usage: Double Tanh (Double X);

Example:

#include

#include

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;

}

Function name: Tell

Function: Take the current location of the file pointer

Usage: Long Tell (int Handle);

Example:

#include

#include

#include

#include

Int main (void)

{

INT HANDLE;

CHAR MSG [] = "Hello World";

IF (("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;

}

Function name: Textattr

Function: Settings text properties

Usage: void textttr (int attribute);

Example:

#include

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;

}

Function Name: TextbackGround

Function: Choose a new text background color

Usage: Void TextBackground (int color);

Example:

#include

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;

}

Function name: TextColor

Function: Select a new character color in text mode

Usage: Void TextColor (Int Color);

Example:

#include

INT main (void) {

INT I;

FOR (i = 0; i <15; i )

{

TextColor (i);

CPrintf ("Foreground Color / R / N");

}

Return 0;

}

Function name: Textheight

Function: Returns a string height based on pixels

Usage: int Far TextHeight (Char far * textstring);

Example:

#include

#include

#include

#include

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 Initization * /

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;

}

Function name: TextMode

Function: Set the screen into text mode

Usage: Void TextMode (int M);

Example:

#include

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;

}

Function name: TextWidth

Features: Returns a string width in pixels

Usage: int Far Textwidth;

Example:

#include

#include

#include

#include

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 Initization * /

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;

}

Function name: Time

Function: Take a day

Usage: LOGN TIME (long * tloc);

Example:

#include

#include

#include

Int main (void)

{

Time_t t;

T = Time (NULL);

Printf ("The Number of Seconds Since January 1, 1970 IS% LD", T);

Return 0;

}

Function name: TMPFILE

Function: Open a temporary file in binary

Usage: file * tmpfile (void);

Example:

#include

#include

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;

}

Function name: TMPNAM

Function: Create a unique file name

Usage: char * tmpnam (char * sptr);

#include

Int main (void)

{

CHAR Name [13];

TMPNAM (Name);

Printf ("Temporary Name:% S / N", NAME);

Return 0;

}

Function Name: TOLOWER

Function: Convert characters to lowercase letters

Usage: int Tolower (INT C);

Example:

#include

#include

#include

Int main (void)

{

Int Length, i;

Char * String = "this is a string";

Length = Strlen (String);

For (i = 0; i

{

String [i] = tolower (String [i]);

}

Printf ("% s / n", string);

Return 0;

}

Function name: TouPper

Function: Convert characters to uppercase letters

Usage: int Toupper (INT C);

Example:

#include

#include

#include

Int main (void)

{

Int Length, i;

Char * String = "this is a string";

Length = Strlen (String);

For (i = 0; i

{

String [I] = Toupper (String [i]);

}

Printf ("% s / n", string);

Return 0;

}

Function name: tzset

Function: UNIX Time Compatibility

Usage: void Tzset (Void);

Example:

#include

#include

#include

Int main (void)

{

Time_t td;

Putenv ("tz = pst8pdt");

Tzset ();

TIME (& TD);

Printf ("Current Time =% S / N", ASCTIME (LocalTime (& TD)));

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-74421.html

New Post(0)