填空題
請補(bǔ)充main函數(shù),該函數(shù)的功能是:從一個字符串中截取前面若干個給定字符數(shù)的子字符串。其沖,str1指向原字符串,截取后的字符串存放在str2所指的字符數(shù)組中,n中存放預(yù)截取的字符個數(shù)。
例如,當(dāng)str1=”abcdefg”,然后輸入3,則str2=”abc”.
注意:部分源程序給出如下
僅在橫線上填入所編寫的若干表達(dá)式或語句,請勿改動函數(shù)中的任何內(nèi)容。
試題程序:# include
# include
# define LEN 80
main()
{
char str1[LEN], str2[LEN];
int n, i;
printf("Enter the string:\n");
gets(str1);
printf("Enter the position of the string deleted:");
scanf(___1___);
for (i=0; i
___2___
str2[i] = '\0';
printf("The new string is:%s\n", ___3___);
}
第1處填空:”%d”,&n
第2處填空:str2[i]=str1[i]
第3處填空:str2