摘要: #include void copyString (char *to, char *from) { while ( *from ) // from指针遇到空指针的时候结束循环(字符串的最后一个字符为\0,也就是空指针,空指针和0等价) *to++ = *from++; // 将from指针指向的值赋值给to指针指向的值,然后两个指针分别递增1 ... 阅读全文
posted @ 2018-01-24 22:30 ranwuer 阅读(5289) 评论(0) 推荐(0) 编辑
摘要: #include int stringLength (const char *string) { const char *cptr = string; while ( *cptr ) ++cptr; return cptr - string; //cptr表示指向字符串的\0字符的位置,string表示指向字符串的第一个字符的位置,所以两者相减就是字... 阅读全文
posted @ 2018-01-24 00:42 ranwuer 阅读(5018) 评论(0) 推荐(1) 编辑