1、通过putchar获取指定数字的图形:比如putchar(97);会输出英语字母a,标明ASCII码97对应小写字母a 。

3、通过putchar实现字符串的打印函数:#include <stdio.h>#include &造婷用痃lt;stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */void PrintString(char *str){while(*str){putchar(*str);str ++;}}int main(int argc, char *argv[]) {char *str = "Hello world !\r\n";PrintString(str);return 0;}

5、虽然putchar接收的是int型参数,不小于2字节,但是它实际是按照ASCII码处理的,即只具备一个字节的字符输出能力,所以对于占用2个字节的汉字需要分开输出:#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {putchar(0xd6); //汉字"中" GB2312编码高字节 putchar(0xd0); //汉字"中" GB2312编码低字节 putchar(0xB9); //汉字"国" GB2312编码高字节putchar(0xFA); //汉字"国" GB2312编码低字节return 0;}
