Submit: 764 Solved: 465
[Submit][Status][Web Board]
Description
有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。
Input
数字n 一行字符串数字m
Output
从m开始的子串
Sample Input
6
abcdef
3
Sample Output
cdef
int
strcpypos(
char
s2[],
char
s1[],
int
pos)
{
int
i,j;
j=
strlen
(s1);
for
(i=pos-1;i<=j;i++)
{
s2[i-(pos-1)]=s1[i];
}
s2[j]=
'\0'
;
}
int
main()
{
char
s1[256],s2[256];
int
n,pos,i;
scanf
(
"%d"
,&n);
getchar
();
for
(i=0;i<n;i++)
scanf
(
"%c"
,&s1[i]);
s1[n]=
'\0'
;
scanf
(
"%d"
,&pos);
strcpypos(s2,s1,pos);
printf
(
"%s\n"
,s2);
return
0;
}