1 void strmcpy(char *t, int m, char *s) 2 { 3 int len = 0; //计算字符串t的长度 4 char *p = t; 5 int i; 6 while (*p != ‘\0‘) 7 { 8 len++; 9 p++; 10 } 11 12 if (m <= len) 13 { 14 for (i = 0; t[m - 1 + i] != ‘\0‘; i++) 15 { 16 s[i] = t[m - 1 + i]; 17 } 18 s[i] = ‘\0‘; 19 } 20 else 21 { 22 *s = ‘\0‘; 23 } 24 }
原文地址:https://www.cnblogs.com/2018jason/p/12072393.html
时间: 2024-10-09 23:57:51