Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to output bytes in C language
How to output bytes in C language
A)putchar function: output the specified character (value corresponding to the expression) to the standard output terminal (screen).

Format: int putchar (int c);

For example: putchar ('a'+3); The printed result is d, which is a character rather than a numerical value.

The ASCII code of A is 97. Adding 3 to the ASCII code table is 100, and the corresponding character is D.

For example: Putchar (99); The result of printing is C. Replace a number and print a character.

It's like printing out the name instead of the admission number.

B)putc function: output the specified characters to the specified standard output stream (screen or file).

Format: int putc( int c, file * stream);

C) Equivalence: putc's functions include putchar's functions.

Putchar(c) is equivalent to putc(c, stdout).

For example, putc ('a', stdout) is equivalent to putchar('A' a').

Extended data

Character alignment in c language

1, self-aligned value of data type: for char data, its self-aligned value is 1, for short type is 2, and for int, float and double type, its self-aligned value is 4, unit byte.

2. Self-aligned value of complex type (such as union, structure or class): the value with the largest self-aligned value among its members.

3. When the alignment value is #pragma pack (value), specify the alignment value.

4. Effective alignment values of data members and complex types (such as union, structure or class): the smaller of self-alignment value and specified alignment value.

Baidu encyclopedia -C language