When are you able to return NULL as the returning value of a C function?

后端 未结 5 1681
不思量自难忘°
不思量自难忘° 2021-01-26 07:22

I was wondering if you could tell me when you are able to return NULL, as the result of a function in C.

For instance int lenght() can\'t retur

5条回答
  •  执笔经年
    2021-01-26 07:47

    When are you able to return NULL as the returning value of a C function

    In general, if and only if the function returns a pointer type:

    T * function( | void>); /* With T being any valid type. */
    

    There are other, corner cases, which depend on the C implementation in use.

提交回复
热议问题