习题8-5使用函数实现字符串复制(20分)
发布时间
阅读量:
阅读量
本题需要设计一个函数,其功能是将输入字符串t中自第m个字符起的所有字符内容,完整地复制至字符串s中。
函数接口定义:
void strmcpy( char *t, int m, char *s );
字符串复制函数strmcpy的作用是将输入的字符指针t所指向的字符串中,从第m个字符位置起始的所有字符内容,完整地拷贝至字符指针s所指向的目标字符串中。当参数m的值大于输入字符串的实际长度时,目标字符串应被置为空字符串。
#include <stdio.h>
#define MAXN 20
void strmcpy( char *t, int m, char *s );
void ReadString( char s[] ); /* 由裁判实现,略去不表 */
int main()
{
char t[MAXN], s[MAXN];
int m;
scanf("%d\n", &m);
ReadString(t);
strmcpy( t, m, s );
printf("%s\n", s);
return 0;
}
/* 你的代码将
全部评论 (0)
还没有任何评论哟~
