当前位置:网站首页>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
边栏推荐
- [problem solving] 'ASCII' codec can't encode characters in position XX XX: ordinal not in range (128)
- 微信中金财富高端专区安全吗,证券如何开户呢
- Mysql database and table building: the difference between utf8 and utf8mb4
- PCL点云处理之计算两平面交线(五十一)
- Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
- nc基础用法1
- What is the difference between a host and a server?
- The ODB model calculates the data and outputs it to excel
- 中金财富公司怎么样,开户安全吗
- Computing the intersection of two planes in PCL point cloud processing (51)
猜你喜欢
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code
Livego + ffmpeg + RTMP + flvjs to realize live video
go-zero框架数据库方面避坑指南
Five minutes to show you what JWT is
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
Leetcode dynamic planning training camp (1-5 days)
Plato Farm元宇宙IEO上线四大,链上交易颇高
AQS learning
Modeling based on catiav6
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
随机推荐
Fundamentals of network communication (LAN, Wan, IP address, port number, protocol, encapsulation and distribution)
Experience of mathematical modeling in 18 year research competition
NC basic usage 1
Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
Common form verification
微信中金财富高端专区安全吗,证券如何开户呢
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
NC basic usage 4
Recommend an open source free drawing software draw IO exportable vector graph
DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS
Leetcode dynamic planning training camp (1-5 days)
R language ggplot2 visualization: ggplot2 visualizes the scatter diagram and uses geom_ mark_ The ellipse function adds ellipses around data points of data clusters or data groups for annotation
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
Cadence Orcad Capture CIS更换元器件之Link Database 功能介绍图文教程及视频演示
Development of Matlab GUI bridge auxiliary Designer (functional introduction)
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
Local call feign interface message 404
Automatically fill in body temperature and win10 task plan
【问题解决】‘ascii‘ codec can‘t encode characters in position xx-xx: ordinal not in range(128)