strlen() : 获取字符串长度
strcpy() : 字符串的拷贝
strcmp() : 字符串比较
一、模拟实现strlen()函数
1.用指针模拟实现
#include <stdio.h>
#include <stdlib.h>
int mystrlen(const char *s){
int cnt;
for(cnt=0; *s!='\0';cnt++)
s++;
return cnt;
}
int main(void){
char *buf = "hehe";
printf("len = %d\n",mystrlen(buf));