题目内容:
请编写一个函数void proc(char a[],char b[],int n),其功能是:删除一个字符串中指定下标的字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,n中存放指定的下标。 例如,输入一个字符串student,然后输入5,则调用该函数后的结果为studet。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define N 20
void proc(char a[],char b[],int n)
{ }
void main()
{
char str1[N],str2[N];
int n;
system("CLS");
printf("Enter the strin9:\n");
gets(str1);
printf("Enter the position of the string deleted:
");
scanf("%d",&n);
proc(str1,str2,n);
printf("The new string is:%s\n",str2);
}
参考答案:
答案解析: