Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can char arrays store integers?
Can char arrays store integers?
Char type is 1 byte integer. As long as the value is in the range of 1 byte, 1 byte can be stored.

For example:

char s[ 10]={ 3 1,32,33,34,35,36,37,38,39,40 };

int I; for(I = 0; I< 10; i++) printf("%d ",s[I]);

Output: 3 1 32 33 34 35 36 37 38 39 40

In addition, you can also store integers as strings:

char s[ 10]= " 1234567 ";

int I;

sscanf(s," %d ",& ampI); //Convert to an integer

printf("%d\n ",I); //output i.

In addition, the binary integer 16 can also be stored as a string. You can use the strtol () function to convert it to an integer. I won't go into details here.