📄 string.c
字号:
/** * string.c - sting library that likes C standard library. * * Copyright (C) 2008 ZhangHu * All rights reserved. * E-MAIL: anmnmnly@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */#include "common/string.h"#include "include/types.h"/** * lib_strcpy - Copy source string to destination string. * @Dest: Pointer to destination string. * @Src: Pointer to source string. * @return: Destination string. * * @notes: */char_t *lib_strcpy(char_t *Dest, const char_t *Src) { char_t *str = Dest; if((Dest == NULL) || (Src == NULL)) { return NULL; } do { *str++ = *Src; } while(*Src++ != '\0'); return Dest;}/** * lib_strcmp - Compare two strings. * @Dest: Pointer to one string. * @Src: Pointer to another string. * @return: 0 if equality. * * @notes: */int lib_strcmp(const char *str1, const char_t *str2) { char_t ch1, ch2; const uchar_t *s1; const uchar_t *s2; s1 = (const uchar_t*)str1; s2 = (const uchar_t*)str2; do { ch1 = (uchar_t)*s1++; ch2 = (uchar_t)*s2++; if(ch1 == '\0') { return ch1 - ch2; } } while(ch1 == ch2); return ch1 - ch2;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -