Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to make C++ convert numbers into corresponding symbols in ASC2 code table for output?
How to make C++ convert numbers into corresponding symbols in ASC2 code table for output?
The range of character values in the ascii code table is 0- 127, and each value corresponds to an ascii character and the ASCII value of the character. The output mode is:

C language mode:

Use the printf () function to output integer values in %d format, characters in %c format and all ascii output codes:

# Contains? & ltstdio.h & gt

Invalid? Master ()

{

int? Me; ? //I can also define it as unsigned here? Charles? Type, the following code makes no difference.

For (? I = 0; I< 128; i++? )?

printf("%c? :? %d\n ",me,? Me? ); ? //Output different types of data in different formats with the same variable value.

}C++ mode:

Directly convert related types, such as:

# Contains? & ltiostream & gt

Use? Namespace? Sexually transmitted diseases ;

Invalid? Master ()

{

For (? int? I = 0; I< 128; i++? )?

cout? & lt& lt? (char)I & lt; & lt"? :?" ? & lt& lt? Me? & lt& ltendl? ; ? //(char)i integer variables are output by characters.

For (? Not signed? Charles? ch = 0; ch & lt 128; ch++? )

cout? & lt& lt? ch & lt& lt"? :?" ? & lt& lt? (int)ch? & lt& ltendl? ; ? //(int)ch character variables are output by shaping.

}