当前位置:网站首页>6-5 字符串 - 2. 字符串复制(赋值) (10 分)C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
6-5 字符串 - 2. 字符串复制(赋值) (10 分)C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
2022-04-23 20:22:00 【Tomatos_baby】
C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
函数原型
char* StrCpy(char *dst, const char *src);
说明:src
为源串的起始地址,dst
为目的串起始地址,函数将 src
串复制到 dst
串,函数值为 dst
。
裁判程序
#include <stdio.h>
#include <string.h>
char* StrCpy(char *dst, const char *src);
int main()
{
char a[1024], b[1024], c[1024];
gets(a);
StrCpy(c, StrCpy(b, a));
puts(a);
puts(b);
puts(c);
return 0;
}
/* 你提交的代码将被嵌在这里 */
输入样例
abcd
输出样例
abcd
abcd
abcd
char* StrCpy(char *dst, const char *src)
{
int i,j;
for(i=0,j=0;src[i]!='\0';i++)
{
dst[j]=src[i];
j++;
}
dst[j]='\0';
return dst;
}
版权声明
本文为[Tomatos_baby]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Tomatos_baby/article/details/124344227
边栏推荐
- Mysql database backup scheme
- Numpy Index & slice & iteration
- Matlab analytic hierarchy process to quickly calculate the weight
- 【PTA】L1-006 连续因子
- WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
- ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
- NC basic usage 1
- 微信中金财富高端专区安全吗,证券如何开户呢
- Operation of numpy array
- Is the wechat CICC wealth high-end zone safe? How to open an account for securities
猜你喜欢
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
STM32 Basics
Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
On BIM data redundancy theory
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Notes of Tang Shu's grammar class in postgraduate entrance examination English
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
Development of Matlab GUI bridge auxiliary Designer (functional introduction)
Monte Carlo py solves the area problem! (save pupils Series)
Browser - learning notes
随机推荐
R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
Investigate why close is required after sqlsession is used in mybatties
考研英语唐叔的语法课笔记
Es error: request contains unrecognized parameter [ignore_throttled]
nc基础用法
selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
Customize timeline component styles
【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
How can matlab obtain the truncated image in trainingimagelabeler
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
Es index (document name) fuzzy query method (database name fuzzy query method)
Notes of Tang Shu's grammar class in postgraduate entrance examination English
【栈和队列专题】—— 滑动窗口
How about CICC fortune? Is it safe to open an account
Markdown < a > tag new page open link
RT-1052学习笔记 - GPIO架构分析
Installation and use of NVM
R语言使用timeROC包计算存在竞争风险情况下的生存资料多时间AUC值、使用cox模型、并添加协变量、R语言使用timeROC包的plotAUCcurve函数可视化多时间生存资料的AUC曲线
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in