您好,请问有知道"putchar"这个函数是怎么用的啊?

格式是怎么样的啊?

PIPIONE
浏览 547回答 3
3回答

慕雪6442864

putchar函数是单个字符输出函数。只输出一个字符。putchar函数的基本格式为:putchar(c)。(1)当c为一个被单引号(英文状态下)引起来的字符时,输出该字符(注:该字符也可为转义字符);(2)当c为一个介于0~127(包括0及127)之间的十进制整型数时,它会被视为对应字符的ASCII代码,输出该ASCII代码对应的字符;(3)当c为一个事先用char定义好的字符型变量时,输出该变量所指向的字符。例: putchar函数的格式和使用方法。#include "stdio.h"void main(){char ch1='N', ch2='E', ch3='W';putchar(ch1); putchar(ch2); putchar(ch3);putchar('\n');putchar(ch1); putchar('\n');putchar('E'); putchar('\n');putchar(ch3); putchar('\n');}程序运行结果如下:NEWNEW扩展资料:c语言函数之一,作用是向终端输出一个字符。其格式为putchar(c),其中c可以是被单引号(英文状态下)引起来的一个字符,可以是介于0~127之间的一个十进制整型数(包含0和127),也可以是事先用char定义好的一个字符型变量。

蓝山帝景

putchar函数用于将一个字符输出到标准输出。  putchar函数的原型为:  int putchar ( int character );  putchar函数接受一个int参数character作为形参,将character作为编码在机器上所代表的字符(通常为ASCII码)输出到标准输出。函数等价于调用putc(character, stdout)。如果输出成功,函数返回输出的字符在机器上的编码(即等于character);如果输出失败,函数返回EOF。/*&nbsp;putchar&nbsp;example:&nbsp;printing&nbsp;the&nbsp;alphabet&nbsp;*/#include&nbsp;<stdio.h>&nbsp;int&nbsp;main&nbsp;(){&nbsp;&nbsp;char&nbsp;c;&nbsp;&nbsp;for&nbsp;(c&nbsp;=&nbsp;'A'&nbsp;;&nbsp;c&nbsp;<=&nbsp;'Z'&nbsp;;&nbsp;c++)&nbsp;putchar&nbsp;(c);&nbsp;&nbsp;&nbsp;return&nbsp;0;}  输出为:ABCDEFGHIJKLMNOPQRSTUVWXYZ

慕妹3242003

putchar 在屏幕上输出一个字符,不需格式#include<stdio.h>void main(){char a[]="abc123";putchar(a[0]);putchar(a[5]);exit(0);}putchar(a[0]); 输出 aputchar(a[5]); 输出 3
打开App,查看更多内容
随时随地看视频慕课网APP