TC Run Library Function Introduction

xiaoxiao2021-03-05  26

For many students who have just contacted C language and TC environments, learning-oriented and structured ideas and C language syntax are the top priority in learning, but they have a relatively firm foundation for this. Continue to improve, one is to learn some commonly used processing methods and computers in storage data, we call algorithms and data structures, which enables you to solve the problem. The number of questions is large. To learn the language and the environment you are using, you can use the resources that can be used directly, that is, the library.

With the rapid development of computer technology, the scale we have to deal with and solve is getting bigger and bigger, and the structure is getting more complicated. This determines that we can't write from zero when we program, and apply Many ready-made code enables comparison, which is often reflected in the form of library functions in the form of library functions. Many functions in the C language offer a function of a particular purpose, which makes your programming efficiency improve and make the logic of the program clearer.

Preparatory knowledge

Some students feel particularly painful when learning the library function, some of which are caused by the basic concepts of language. For C language, you must use the library function to be skilled, there must be a comprehensive and accurate understanding of the process of the call mechanism, the transfer process of the intersection, and the return value of the return value. Contact, fully grasp these knowledge to understand what the function written by others is in the function of interface and implementation. Also, if you are not only available to use the functions in the library, you will have the ability to program the program by exploising their code, then you also need to have a strong ability to read the program. Most common library function introduction

Even for beginners, there are also some functions that are unavoidable in the process of practice programming. It is necessary for this frequent function to use frequent functions. In fact, these functions usually focus on the following header files. : , and .

Declare most of the functions of the C language about the input and output operations, we only need to call these functions to process the input and output without taking into account hardware issues. Everyone starts from the language of contact, even the simplest "Hello, World" program also wants to write a row in #include in the program, and can be seen in this header file.

The list of common functions in this header file on standard input and output is as follows:

Function name function prototype specific function

Scanf int Scanf (Const Char * Format [, Argument] ...); read data from the standard input device, and can write data to the required location according to the requirements of Argument

Printf Int Printf (const char * format [, argument] ...); format all data and output together to standard output devices

Gets Char * Gets (Char * Buffer); obtains a strong data from standard input data streams and stores in buffer. It will take all input characters directly until they want to change line

PUTS INT PUTS (Const Char * String); outputs the specified string to the standard output device

GetChar Int getchar (void); reads a character by the standard input device

PUTC INT PUTC (INT C); output a single character to standard output device

In addition to functions regarding standard input and output, it also declares that a large number of functions related to file read and write operations, which are similar to part of these functions and standard input output, but the data stream is changed to the file. On; another part is basic operations provided for file opening, closing, and file pointer orientation, and students can review them after learning the content related to file operation. In addition, the SSCANF and SPRINTF in can use a string to read and write operations, which can provide a large convenience for data conversion in some specific occasions. Declared library function to handle related mathematical problems, most of these mathematical functions are data that acts on floating point number, including the functions of triangle function, index logarithm, absolute Values ​​and some basic numerical processing, now summarize these functions with the following table:

Function range function name function prototype specific function

Triangular function

Anti-triangular function sin double (double x); calculate sinusoidal value of X radians

Cos Double Cos (Double X); calculate the cosine value of the X curness

Tan Double Tan (double X); calculate the positive cut value of the X radia

Asin Double Asin (double X); calculate an absolute value of no more than 1 anti-sinuming value

ACOS DOUBLE ACOS (Double X); the anti-surpass value of the floating point number of the absolute value is not more than 1

Atan Double Atan; Calculating an annectious value of the floating point number

Index log number log double log (double x); natural logarithmic value of calculating positive floats

Log10 Double Log10 (Double X); calculates the log value of 10 for 10

Pow Double Pow (Double X, Double Y); calculates x y

Exp Double EXP (Double X); calculating E of X

SQRT Double SQRT (Double X); Calculate the square root of the non-negative floating point

The absolute value calculates the Fabs Double Fabs (Double X); the absolute value of the floating point number

Value processing CEIL DOUBLE CEIL (Double X); finds a minimum integer greater than one floating point number

Floor Double Floor (Double X); to find the maximum integer smaller than one floating point number

MODF DOUBLE MODF (Double X, INT * INTPTR); the fractional part of the floating point number, the integer part writes the second parameter pointing to the address

FMOD DOUBLE FMOD (Double X, Double Y); Residual number after two floats

Familiar with functions in math libraries is an essential ring in the learning programming process, because these functions have a higher frequency of use as input and output functions, and some of them are difficult to write the source code implementation.

declares a number of fairly basic functions, allowing C language users to implement powerful features, which involve data type conversion, memory operation, random number processing, sorting, and program flow Control and other content, in the following table, the author focuses on the data type conversion and the random number to handle the common functions of the two beginners, and the function reader of the memory operation can be

http://www.frontfree.net/articles/services/view.asp?id=504&page=1

Find more detailed descriptions.

Function range function name function prototype specific function

Data type conversion ATOF DOUBLE ATOF (const char * string); convert a string into a floating point type

Atoi int atoi; convert a string into an integer type

Atol long atol (const char * string); convert a string to long integer type

ITOA Char * ITOA (int value); converts the value of the integer type into a string, Radix describes the choice of the credit, ranging from 2 to 36 FCVT Char * FCVT (Double Value, Int Count, INT * DEC, INT * SIGN; convert the floating point number into a string, the value to be converted, the count is the number of digits after the decimal point, the decimal point is located, SIGN Description Lag

Random SRAND VOID SRAND (Unsigned INT Seed); Setting Random Seeds

Rand int rand (void); randomly generates a value

Several several function functions declared by the commonly used header files

In addition to , and , there are also some commonly used functions, which summarizes the functionality of the function declared by some headers.

Description of the function of the function declared in the header file

Sets the insertion point during the program execution, which makes the programmer to perform

Processing time, easy programmer to use the system

various processes for strings

related to characters

Treatment related to graphical interface

Conclusion

This article describes the most commonly used very little one of the library functions provided in the C language and TC environments library. Many theoretical and applications involved in the library function requires readers to understand the principles and mechanisms of the language itself. Get a thorough experience. In addition, the author suggests that you can refer to the implementation of the library function while learning related content, because these codes are mostly simple and refined, can be used as a good textbook. For example, eating the original code of the various functions declared in , then you have a big increase in the capabilities and feelings of string and the awareness of pointers. In short, in addition to improving your programming efficiency, the library function allows you to safely use some quality parts, and help you consolidate the knowledge you have learned, improve the ability to read the code, tell you how steel is made up.

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

New Post(0)