当前位置:网站首页>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
边栏推荐
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
- Leetcode dynamic planning training camp (1-5 days)
- 【问题解决】‘ascii‘ codec can‘t encode characters in position xx-xx: ordinal not in range(128)
- LeetCode 20、有效的括号
- [PTA] get rid of singles
- Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
- selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- Numpy - creation of data type and array
- 2022 - Data Warehouse - [time dimension table] - year, week and holiday
- How to protect ECs from hacker attacks?
猜你喜欢
On BIM data redundancy theory
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
How to protect ECs from hacker attacks?
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
Fundamentals of network communication (LAN, Wan, IP address, port number, protocol, encapsulation and distribution)
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
16MySQL之DCL 中 COMMIT和ROllBACK
【PTA】整除光棍
C migration project record: modify namespace and folder name
随机推荐
How can matlab obtain the truncated image in trainingimagelabeler
Sqoop imports tinyint type fields to boolean type
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
LeetCode 1351、统计有序矩阵中的负数
Devexpress 14.1 installation record
Operation of numpy array
How do BIM swindlers cheat? (turn)
Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
A useless confession artifact
XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
三十.什么是vm和vc?
Servlet learning notes
LeetCode 20、有效的括号
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
Monte Carlo py solves the area problem! (save pupils Series)
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
16MySQL之DCL 中 COMMIT和ROllBACK