// ConsoleApplication32.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <stdio.h>
#include <assert.h>
#include <string.h>
char* my_strcpy(char* copy, const char* proto)
{
char* ret = copy;
assert(copy != NULL);
assert(proto != NULL);
while (*copy++ = *proto++);
*copy = *proto;
return ret;
}
char* my_strcat(char* destination,const char* source)
{
assert(source != NULL);
assert(destination != NULL);
char* ret = destination;
while (*destination)
destination++;
while (*destination++ = *source++);
*destination = *source;
return ret;
}
char* my_strstr(char* str1,const char* str2)
{
assert(str1 != NULL);
assert(str2 != NULL);
const char* p = str1;
const char* q = str2;
while (*str1)
{
while (*p && *q && *p++ == *q++);
if (*q == '\0')
return str1;
str1++
自定义str函数
最新推荐文章于 2021-07-21 22:16:57 发布
本文介绍了Python中如何自定义str函数,通过实例展示了自定义字符串格式化的具体步骤和方法,包括利用__str__方法、format函数以及f-string等技术,帮助开发者更好地控制输出的字符串格式。
摘要由CSDN通过智能技术生成