mirror of
https://github.com/huihut/interview.git
synced 2024-03-22 13:10:48 +08:00
commit
6cef0f5a09
|
@ -230,10 +230,15 @@ int main()
|
||||||
|
|
||||||
### assert()
|
### assert()
|
||||||
|
|
||||||
断言,是宏,而非函数。assert 宏的原型定义在`<assert.h>`(C)、`<cassert>`(C++)中,其作用是如果它的条件返回错误,则终止程序执行。如:
|
断言,是宏,而非函数。assert 宏的原型定义在`<assert.h>`(C)、`<cassert>`(C++)中,其作用是如果它的条件返回错误,则终止程序执行。可以通过定义`NDEBUG`来关闭assert,但是需要在源代码的开头,`include <assert.h>` 之前。如:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
assert( p != NULL );
|
assert( p != NULL );
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
assert( p != NULL ); //disable assert
|
||||||
```
|
```
|
||||||
|
|
||||||
### sizeof()
|
### sizeof()
|
||||||
|
@ -3171,4 +3176,4 @@ int main( void )
|
||||||
|
|
||||||
### Segmentfault
|
### Segmentfault
|
||||||
|
|
||||||
* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529)
|
* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user