1. 处理函数
- strlen()
- strlen(s),sizeof(s):test = “hello\0world” ==> 5 “hello\0world” ==> 12
- 在字符串连接和复制后,strlen(s)会发生变化
- strcpy():覆盖+添0,返回char* dst
- strcat():在dst后覆盖+添0,返回char* dst

- strcmp():字符串相减
- strncpy,strncats,strncmp
2. 复合赋值
while(dst++)
dst
++
判断
dst++ = src++
dst
++
src
++
赋值
while(*s) //指向0while(*++s)//指向0while(*s++)//指向0的下一个

MyStrFunc:
#include <stdio.h>#include <string.h>int MyStrlen(const char* s){//下标int cnt = 0;for(int i=0; s[i]; i++)cnt++;return cnt;//// //下标优化// int i = 0;// while(s[i++]);// return --i;//// //指针//// int cnt = 0;//// while(*s++)//// cnt++;//// return cnt;//// //指针//// char const* start = s;//// while(*s++);//// return s-start-1;}char* MyStrcp(char* dst, const char* src){//下标// int i;// for(i=0; src[i]; i++)// {// dst[i] = src[i];// }// dst[i] = 0;//// return dst;// //下标优化// int i = 0;// while(dst[i]=src[i++]);// return dst;//指针char* p = dst;while(*dst++ = *src++);return p;}char* MyStrcat(char* dst, const char* src){//下标int len = strlen(dst);int i;for(i=0; src[i]; i++){dst[len+i] = src[i];}dst[len+i] = 0;return dst;//指针// char* p = dst;// while(*++dst);// while(*dst++ = *src++);// return p;}int MyStrcmp(const char* s1, const char* s2){for(int i=0; s1[i] && s2[i]; i++){if(s1[i]!=s2[i])return s1[i]-s2[i];}return 0;}int main(){char s[15] = {'h','i',0,0,0,0,'h','e','r','e'};// printf("%d\n", MyStrlen(s));char src[10] = "world";// puts(MyStrcp(s,src));char test[5] = "test";// puts(MyStrcat(s,test));// printf("%d %d\n", strcmp(s,src), MyStrcmp(s,src));return 0;}
