---
title: "C语言中常用字符串函数的实现"
author: "lee_3do"
date: "2010-10-07T15:11:33Z"
tags: []
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2010-10-08T19:46:17Z"
id: 778158
url: "https://lee3do.iteye.com/blog/778158"
---

假期最后一天了，继续。

 

```
//字符串长度
int strlen(char *s)
{
    int i=0;
    while(*s++)
        i++;
     return i;
}
```

 //字符串拷贝

```
void strcpy(char *s,char *t)
{
    while(*s++=*t++)
    ;
}
```

 //字符串比较

```
 int strcmp(char *s,char *t)
 {
        while((*s++)==(*t++))//貌似标准库里不是这样实现的...
             if(*s=='\0')
                return 0;
          return *s-*t;
        
 }
```