我该怎么做? TIA int永远不会有没有值。 C不像SQL那样整数 变量可以有null和整数值。 AC变量 可能有一个未初始化或未定义的值,在这种情况下它可能 有任何值,但这与变量无法区分 分配该值。它可能有某种陷阱值b / b值,这是不能测试的,因为如果你尝试程序终止。 指针可能有一个NULL值,这与没有 值不一样。 Gordon L. Burditt I''ve really tried searching for this before I thought of bother you guyswith this question. It''s such a simple thing, but it''s driving me nuts!Is it possible to check if an int (or any other type) has no value.something like: int i;.........if (i==NULL){......} I know this doesn''t work and I know NULL is a pointer. Is there any waythis can be done?TIA. 解决方案 Scalar types, such as ints, always have values. Therefore your questiondoes not make sense. --/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/"Parthenogenetic procreation in humans will result in the founding of a newreligion."- John Nordberg Scalar types, such as ints, always have values. Therefore your question does not make sense. Okay, than I should be more spesific.I''ve got this: typdef struct{int x;int y;} Point; // I now want to make a function that checks if a Point is empty int pointEmpty(Point p){return (p /*isEmpty*/ ? 1 : 0)} How should I do that?TIA An int never has "no value". C is not like SQL where integervariables can have null as well as integer values. A C variablemay have an uninitialized or undefined value, in which case it mighthave any value, but this is not distinguishable from a variablethat is assigned that value. It might have some kind of trappingvalue, which can''t be tested because if you try the program terminates. Pointers may have a NULL value, which is not the same thing as "novalue". Gordon L. Burditt 这篇关于如何确定int是否没有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-31 01:31