Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Conversion of characters to integers in C language
Conversion of characters to integers in C language
You can use the atoi function to convert a string into an integer.

Function prototype: Intatoi (constchar * nptr);

Function: Converts a string to an integer.

Parameter nptr string. If the first non-blank character exists, it is a number or symbol, and it will start type conversion. After that, when a non-numeric character (including the terminator \0) is detected, it will stop the conversion and return an integer. Otherwise, zero is returned.

Extended data:

Use the itoa function to convert integers into characters. Prototype: externchar * itoa (int I);

Reference code:

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

int? Master ()

{

int? a = 125;

Charles? b[50];

printf("%s\n ",itoa(a,b, 10)); //Convert 125 in base 10 into characters for output.

Return? 0;

}

/*