题目:
编写函数strmcpy(s,t,m),该函数将字符串t中从m个字符开始的全部字符复制到字符串s。在主程序中输入字符串t和开始位置m,调用strmcpy(s,t,m)函数,然后输出字符串s。例如,输入字符串liwangzhajinxiao和开始位置2,输出wangzhajinxiao。
代码:
#include<stdio.h>
#define N 100
void strmcpy(char* s, char* t, int m)
{
for (int i = 0; s[m] != '\0'; i++)
{
t[i] = s[m];
m++;
}
}
int main()
{
char t[N] = { };
char s[N] = { };
int m;
printf("输入字符串:");
scanf("%s", &t);
printf("输入正整数m:");
scanf("%d", &m);
strmcpy(s, t, m);
printf("%s", s);
return 0;
}