Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert a string into an integer and output it in C language?
How to convert a string into an integer and output it in C language?
In C language, you can use the atoi () function to convert a string into an integer and output it.

Atoi (ascii to integer) is a function that converts character strings into integers, which is used in computer programs and office software. Int atoi(const char *nptr) function scans the parameter nptr string and skips leading white space characters (such as spaces and tab indentation).

If nptr cannot be converted to int or nptr is an empty string, it will return 0. In particular, this function requires that the converted string be understood as a decimal number. The number corresponding to the string input by atoi has a size limit (related to the size of the int type). If it is too large, an error of-1 may be given.

Extended data:

Common functions of C language:

1、int abs(int i)

Returns the absolute value of integer parameter i.

2. Double cab (complex structure znum)

Returns the absolute value of the complex number znum.

3. Double Wafer Factory (Double X)

Returns the absolute value of the double-precision parameter x.

4. Long Laboratory (long n)

Returns the absolute value of the long integer parameter n.

5. Double exp (Double X)

Returns the value of the exponential function ex.

6、double frexp(double value,int *eptr)

Returns the value of x in value=x*2n, where n is stored in eptr.

7、double ldexp(double value,int exp)

Returns the value of value*2exp.

8. Double Logarithm (Double X)

Returns the value of logex.

9, double logarithm 10 (double x)

Returns the value of log 10x.

10, double power (double x, double y)

Returns the value of x y.

Baidu encyclopedia -atoi