C/C++中用空指针简化代码实例
16lz
2021-01-22
这里的写法,可以避免使用 for 循环,减少栈空间内存的使用和减少运行时的计算开销!
#include iostream> #include string> usingnamespacestd; void print_char(char* array[]);//函数原形声明 void main(void) { char* test[]={"abc","cde","fgh",NULL};//这里添加一个NULL,表示不指向任何地址,值为0 print_char(test); cin.get(); } void print_char(char* array[]) { while(*array!=NULL) { cout } }
更多相关文章
- 原来斐波拉契数列还有这种写法,你知道吗?
- golang不定长参数写法
- 广告控件中xml文件的写法
- 正则表达式在 ES2018 中的新写法 [每日前端夜话0x25]
- 详解PHP死循环写法和作用
- PHP让人不知道的匿名函数的几种写法(附代码)
- 学习PHP死循环写法和作用
- 详细解说三种PHP嵌套HTML的写法
- PHP+Swoole的闭包写法