69,382
社区成员
发帖
与我相关
我的任务
分享
#include "stdio.h"
#include "Conio.h"
void copychar(char *p1,char *p2,int m)
{
int n=0;
while(n <m-1)
{
n++;
p1++;
}
while(*p1!='\0')
{
*p2=*p1;
p1++;
p2++;
}
*p2='\0';
}
int main(void)
{
char str1[20],str2[10];
int n;
printf("input the char:");
gets(str1);
printf("the number is;");
scanf("%d",&n);
copychar(str1,str2,n);
puts(str2);
fflush();
getch();
return 0;
}