标签:style blog color ar for sp div log as
1 /* 2 input:一个4位整数. 3 output:每位整数后紧跟一个空格的字符串. 4 */ 5 char * 6 insert(char *s) { 7 int len = strlen(s); 8 char *n = (char *)malloc(2 * len + 1); 9 char *f = n; //存首地址. 10 for(int i = 0; i < len; i++) { 11 *n++ = *s; 12 *n++ = ‘ ‘; //数字后加一个空格. 13 s++; 14 } 15 *n = ‘\0‘; //在尾部注明结束符. 16 return f; 17 }
这里比较容易忘记的是在尾部标注结束符.
标签:style blog color ar for sp div log as
原文地址:http://www.cnblogs.com/listened/p/4049111.html