什么是" -1L"用C? [英] What is "-1L" in C?
问题描述
什么是-1L,1L等意思?
What do "-1L", "1L" etc. mean in C ?
例如,在 FTELL 参考,它说:
...如果发生错误,则返回-1L ...
... If an error occurs, -1L is returned ...
这是什么意思?什么是1L的类型?
What does this mean ? What is the type of "1L" ?
为什么不返回NULL,如果发生错误?
Why not return NULL, if error occurs ?
推荐答案
的→
指定号码是长
类型,所以 -1L
是长
设置为负一和 1L
是长
设置为积极的。
The L
specifies that the number is a long
type, so -1L
is a long
set to negative one, and 1L
is a long
set to positive one.
至于为什么 FTELL
不只是返回 NULL
,这是因为 NULL
用于指针,这里长
被返回。需要注意的是 0
未使用,因为 0
是 FTELL $有效值C $ C>返回。
As for why ftell
doesn't just return NULL
, it's because NULL
is used for pointers, and here a long
is returned. Note that 0
isn't used because 0
is a valid value for ftell
to return.
捕捉这种情况包括检查一个非负值
Catching this situation involves checking for a non-negative value:
long size;
FILE *pFile;
...
size = ftell(pFile);
if(size > -1L){
// size is a valid value
}else{
// error occurred
}
这篇关于什么是" -1L"用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!