当前位置:网站首页>6-5 string - 2 String copy (assignment) (10 points) the C language standard function library includes the strcpy function for string copy (assignment). As an exercise, we write a function with the sam
6-5 string - 2 String copy (assignment) (10 points) the C language standard function library includes the strcpy function for string copy (assignment). As an exercise, we write a function with the sam
2022-04-23 20:27:00 【Tomatos_ baby】
C The language standard function library includes strcpy function , For string copying ( assignment ). As a practice , We write a function with the same function .
The function prototype
char* StrCpy(char *dst, const char *src);
explain :src
Is the starting address of the source string ,dst
The starting address of the string for the purpose , Function will src
Copy string to dst
strand , Function value is dst
.
judging procedures
#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;
}
/* The code you submit will be embedded here */
sample input
abcd
sample output
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://yzsam.com/2022/04/202204232022015387.html
边栏推荐
- R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
- 16MySQL之DCL 中 COMMIT和ROllBACK
- 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
- Use the rolling division method to find the maximum common divisor of two numbers
- [stack and queue topics] - sliding window
- 论文写作 19: 会议论文与期刊论文的区别
- Automatically fill in body temperature and win10 task plan
- 上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
- SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
- XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
猜你喜欢
What is the difference between a host and a server?
Browser - learning notes
Commande dos pour la pénétration de l'Intranet
【PTA】L1-002 打印沙漏
LeetCode 994、腐烂的橘子
内网渗透之DOS命令
. Ren -- the intimate artifact in the field of vertical Recruitment!
[PTA] get rid of singles
Installation and use of NVM
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
随机推荐
16MySQL之DCL 中 COMMIT和ROllBACK
Tensorflow 2 basic operation dictionary
Commande dos pour la pénétration de l'Intranet
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
三十.什么是vm和vc?
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
BMP JPEG 图片转换为矢量图像 ContourTrace
bounding box iou
[problem solving] 'ASCII' codec can't encode characters in position XX XX: ordinal not in range (128)
Matlab analytic hierarchy process to quickly calculate the weight
. Ren -- the intimate artifact in the field of vertical Recruitment!
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Intersection calculation of straight line and plane in PCL point cloud processing (53)
Rt-1052 learning notes - GPIO architecture analysis
C migration project record: modify namespace and folder name
An error is reported when sqoop imports data from Mysql to HDFS: sqlexception in nextkeyvalue
三十一. `prototype`显示原型属性和`__proto__`隐式原型属性
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
Plato Farm元宇宙IEO上线四大,链上交易颇高
Devexpress 14.1 installation record