题目内容:
请补充函数proc(),该函数的功能是:只保留字符串中的大写字母,删除其他字符,结果仍保存在原来的字符串中,由全局变量m对删除后字符串的长度进行保存。 注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdlib.h>
#include<conio.h>
int m;
void proc(char*str)
{
int i=0,j=0;
char*p=str;
while(*(p+i))
{
if(*(p+i)>='A'&&*(p+i)<='Z')
{
【1】 ;
}
【2】 ;
}
str[j]='\0 ';
【3】 ;
}
void main()
{
char str[80];
system("CLS"):
printf("\nEnter a string:");
gets(str);
printf("\n\nThe st{ing is:%s\n",str);
proc(str);
printf("\n\nThe string of changing
is:%s\n",str);
printf("\n\nThe length of changed string
is:%d\n",m);
}
参考答案:【答案仅供学习,请勿对照自行用药等】
答案解析: