C语言里面,put ch和put char有什么区别

如题所述

函数名: putch
功 能: 输出字符到控制台
用 法: int putch(int ch);
程序例:

#include <stdio.h>
#include <conio.h>

int main(void)
{
char ch = 0;

printf("Input a string:");
while ((ch != '\r'))
{
ch = getch();
putch(ch);
}
return 0;
}

函数名: putchar
功 能: 在stdout上输出字符
用 法: int putchar(int ch);
程序例:

#include <stdio.h>

/* define some box-drawing characters */
#define LEFT_TOP 0xDA
#define RIGHT_TOP 0xBF
#define HORIZ 0xC4
#define VERT 0xB3
#define LEFT_BOT 0xC0
#define RIGHT_BOT 0xD9

int main(void)
{
char i, j;

/* draw the top of the box */
putchar(LEFT_TOP);
for (i=0; i<10; i++)
putchar(HORIZ);
putchar(RIGHT_TOP);
putchar('\n');

/* draw the middle */
for (i=0; i<4; i++)
{
putchar(VERT);
for (j=0; j<10; j++)
putchar(' ');
putchar(VERT);
putchar('\n');
}

/* draw the bottom */
putchar(LEFT_BOT);
for (i=0; i<10; i++)
putchar(HORIZ);
putchar(RIGHT_BOT);
putchar('\n');

return 0;
}
温馨提示:答案为网友推荐,仅供参考
相似回答