给定,函数 fun 的功能是:把形参 s 所指字符串中最右边的 n 个字符复制到形参 t 所指字符数组中,形成一个新串。若 s 所指字符串的长度小于 n ,则将整个字符串复制到形参 t 所指字符数组中。 例如,形参 s 所指的字符串为: abcdefgh , n 的值为 5 ,程序执行后 t 所指字符数组中的字符串应为: defgh 。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:部分源程序在文件 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include
#include
#define N 80 void fun(char *s, int n, char *t) { int len,i,j=0; len=strlen(s); /**********found**********/ if(n>=len) strcpy(__1__); else { /**********found**********/ for(i=len-n; i<=len-1; i++) t[j++]= __2__ ; /**********found**********/ t[j]= __3__ ; } } main() { char s[N],t[N]; int n; printf("Enter a string: ");gets(s); printf( "Enter n:"); scanf("%d",&n); fun(s,n,t); printf("The string t : "); puts(t); }