【IT168 编程开发】编写高效简洁的C语言代码,是许多软件工程师追求的目标。本文就是针对编程工作中的一些体c语言编程会和经验做相关的阐述。 第一招:以空间换时间 计算机程序中最大的矛盾是空间和时间的矛盾,那么,从这个角度出发逆向思维来考虑程序的效率问题,我们就有了解决问题的第1招--以空间换时间。比如说字符串的赋值: 方法A:通常的办法c语言编程 #define LEN 32 char string1 [LEN]; memset (string1,0,LEN); strcpy (string1,"This is a example!!"); 方法B: const char string2[LEN] ="This is a example!"; char * cp; cp = string2 ;
c语言编程 #define LEN 32 char string1 [LEN]; memset (string1,0,LEN); strcpy (string1,"This is a example!!");
const char string2[LEN] ="This is a example!"; char * cp; cp = string2 ;