C - 检查是否分配了整数 [英] C - Check if Integer is assigned

查看:101
本文介绍了C - 检查是否分配了整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何判断整数是否未分配?

How do I determine if an integer is unassigned?

int i; /* no assignment */

if (/* conditional statement here to check if int i is unassigned or not */) {
   printf("Integer is unassigned!\n");
} else {
   printf("Integer is assigned!\n");
}


推荐答案

你不能。它将具有未定义内容,这意味着它将包含当时在该内存位置中发生的内容。

You can't. It will have "undefined" content, meaning it'll contain what ever happens to be in that memory location at that time.

。 。 。除非i在全局范围内声明,否则它将初始化为零。

. . . unless i is declared at the global scope, then it will be initialised to Zero.

这篇关于C - 检查是否分配了整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆