Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can char arrays store integer values?
Can char arrays store integer values?
The answer is yes, because all data are represented in binary in the computer.

The first case:

The char character occupies one byte, and the byte itself is expressed as an integer; Char can represent-128- 127, and unsigned char0-255;

The second case:

You want to store int types in the char array, which is ok, as long as the array has enough memory;

For example, general int occupies 4 bytes, and at least charnum [4] should be defined to store it;

For example, int a = 500 character number [4]; ?

You can use memcpy(num,&A, sizeof(int)) to write integer variables into char's num array.