【发布时间】:2012-05-08 17:26:22
【问题描述】:
int i=9999;
char c=i;
不给出溢出警告,While
char c=9999;
给,
警告 C4305 将截断从 int 初始化为 char
为什么在将int 转换为char 时没有溢出警告?
【问题讨论】:
-
@pmg:不,它们都是初始化。
-
你是对的@KeithThompson,谢谢。我删除了错误的评论。
-
@pmg 你的那条评论让我非常困惑,我不得不将它发布在一个单独的问题中。这就是你所说的--
It's not the same thing. The first is an assignment, the second is an initialization。这是链接stackoverflow.com/questions/16500028/…跨度> -
@Rüppell'sVulture:很抱歉。
-
@pmg 实际上,像我这样的 StackOverflow 普通人不会期望像你这样拥有 25k+ 声望的 ace 会出现 ANY 错误..LOL..
标签: c visual-c++