标签:des io ar amp c++ res ad har
#include <stdio.h> #include <assert.h> char* strcpy(char* strDest, const char* strSrc) { assert((strDest != NULL) && (strSrc != NULL)); char* address = strDest; while((*strDest++ = *strSrc++) != '\0') NULL; return address; } char* strncpy(char* strDest, const char* strSrc, int n) { assert((strDest != NULL) && (strSrc != NULL)); char* address = strDest; while(n-- > 0) { *strDest++ = *strSrc++; } return address; } int strlen(const char* str) { assert(str != NULL); int strlen = 0; while((*str++) != "\0") strlen++; return strlen; } int strcmp(const char* str1, const char str2) { assert((str1 != NULL) && (str2 != NULL)); while(*str1 && *str2 && (*str1 == *str2)) { str1++; str2++; } return (*str1 - *str2) } char* strcat(char* strDest, const char* strSrc, int n) { assert((strDest != NULL) && (strSrc != NULL)); char* address = strDest; //不能用*strSest++,否则循环结束好,strDest将指向'\0'的下一个位置 while(*strDest) { strDest++ } while(*strDest++ = *strSrc++) NULL; return address; }
strcpy,strncpy, strlen, strcmp strcat函数实现,布布扣,bubuko.com
strcpy,strncpy, strlen, strcmp strcat函数实现
标签:des io ar amp c++ res ad har
原文地址:http://blog.csdn.net/walkerkalr/article/details/38511201