c语言中字符常量 和 字符串常量

 

001、c语言中字符常量用单引号括起来, 用putchar函数输出。 字符常量是 int类型。  字符常量为什么是int型?

#include <stdio.h>

int main(void)
{
    int i;
    
    for (i = 1; i <= 5; i++)
    {
        putchar('*');            ## 单引号字符常量*, 字符常量是int类型。
    }
    putchar('\n');               ## 单引号字符常量\n, 字符常量是int类型return 0;
}

 

字符常量‘*’ 和 字符串常量“*”的区别。

 

字符常量‘*’ ...... 表示单一的字符*。

字符串常量“*”...... 表示单纯由字符*构成的一连串连续排列的字符。 ???   单纯字符、 一连串连续排列 ??

 

posted @ 2022-08-12 20:48  小鲨鱼2018  阅读(446)  评论(0编辑  收藏  举报