What is “-1L” in C?

前端 未结 6 1474
梦谈多话
梦谈多话 2020-12-10 11:16

What do \"-1L\", \"1L\" etc. mean in C ?

For example, in ftell reference, it says

... If an error occurs, -1L is returned ...

6条回答
  •  鱼传尺愫
    2020-12-10 11:40

    -1 formated in long int is a -1L. Why not simple NULL? Because NULL in this function is a normal result and can't sygnalize error too. Why NULL in this function is a normal result? Because NULL == 0 and ftell returns position in a stream, when you are on start of stream function returns 0 and this is a normal result not error, then if you compare this function to NULL to check error, you will be get error when you will be on start position in stream.

提交回复
热议问题