第39套
填空题
请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定字符数的子字符串。其冲,str1指向原字符串,截取后的字符串存放在str2所指的字符数组中,n中存放预截取的字符个数。
例如,当str1=”abcdefg”,然后输入3,则str2=”abc”.
注意:部分源程序给出如下
仅在横线上填入所编写的若干表达式或语句,请勿改动函数中的任何内容。
试题程序:# 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
编辑特别推荐: