Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert character type into integer type in C language, such as char a [3] =123; int I; for(I = 0; I<A [I]; I++) makes the for statement possible.
How to convert character type into integer type in C language, such as char a [3] =123; int I; for(I = 0; I<A [I]; I++) makes the for statement possible.
# contains "stdio.h"

# contains "string.h"

void main()

{

char a[4]= " 123 "; //Note that the string has a terminator, which takes up one byte.

int n = 0;

int I;

for(I = 0; I< strlen (a); i++)

n = n * 10+a[I]--0;

printf("%d ",n);

}