鱼C论坛

 找回密码
 立即注册
查看: 3169|回复: 1

一些不匹配的整型转换

[复制链接]
发表于 2022-5-24 14:21:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
// intconv.c -- 一些不匹配的整型转换
#include <stdio.h>
#define PAGES 336
#define WORDS 65618
int main(void)
{
        char ch;
       
        const short num = PAGES;
        const short mnum = -PAGES;

        //scanf("%d",&ch);
        printf("%d %c\n",ch,ch);
       
        printf("num as short and unsigned short: %hd %hu\n", num, num);
        printf("-num as short and unsigned short: %hd %hu\n",mnum, mnum);
        printf("num as int and char: %d %c:\n", num, num);
        printf("WORDS as int, short, and char: %d %hd %c\n", WORDS, WORDS, WORDS);
       
        //scanf("%d",&ch);
        //printf("%d %c\n",ch,ch);
        return 0;
}
求助大佬!
scanf截断输入字符值后,打印字符第1、2、3、列打印输出结果不同的原因是什么?
第一段scanf截断造成输出结果不同,scanf放在尾端打可以正常打印的原因是什么?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-5-24 14:43:13 | 显示全部楼层
看不明白你在说什么不同... 把你的输入输出列出来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-8 00:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表