putchar的用法

 时间:2024-11-05 17:27:22

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

putchar的用法

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;}

putchar的用法

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;}

putchar的用法
  • C语言的putchar如何使用?
  • getchar的用法
  • C语言中什么是形参,什么是实参
  • C语言中的strcat函数怎样使用?
  • c语言fun函数怎么用
  • 热门搜索
    文昌旅游 铜陵旅游景点大全 中国旅游景点地图 中国旅游饭店行业规范 内蒙旅游网 海南旅游指南 安康旅游景点 广西 旅游 纳木错旅游 中国旅游网站