#include <stdio.h>
#include <string.h>
void fun ( char s[], int n )
{
char a[80] , *p;
int i;
p=s;
for(i=0; i<n; i++) a[i]='*';
do
{ a[i]=*p; //a[i]中i值从for循环n值开始,*p指向的是s[]中值的开始,将s[]中字符放a[]值后面排
i++;
}
while(*p++);//当将s[]的字符排完后,即空值,*p++=0,while()判断条件为false,结束循环
strcpy(s,a);//最后将数组a[]赋予s[]数组中
}
main()
{ int n; char s[80];
printf("\nEnter a string : "); gets(s);
printf("\nThe string \"%s\"\n",s);
printf("\nEnter n ( number of * ) : "); scanf("%d",&n);
fun(s,n);
printf("\nThe string after insert : \"%s\" \n" ,s);
}