填空题 C语言
题号 #2257048

请补充函数proc(),该函数的功能是:依次取出字符串中所有的小写字母以形成新的字符串,并取代原字符串。
例如,若输入:everyONE!,则输出:every。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void proc(char*str)
{
int i=0:
char*p=str;
while(【1】)
{
if(*p>='a'&&*p<='2')
{
str[i]=*P:
【2】 ;
}
p++;
}
str[i]=【3】 ;
}
void main()
{
char str[80];
system("CLS");
printf("\nEnter a string:");
gets(str);
print{("\n\nq he string is:%s\n",str);
proc(str);
printf("\n\nThe string of changing
is:%s\n",str);
}

进入在线模考

参考答案

暂无

答案解析

【l】*P【2】i++【3】 '\0 '
【解析】由函数proc()可知,指针变量P是指向字符串
str的指针,用来判断字符串是否结束,因此,【1】处填“*p”;变量i为新字符串数组的下标,每检查到一个符合要求的字
符,数组下标加1,因此,【2】处填“i++”;最后,要为新的字符串数组添加结束符,因此,【3】处填“'\0'”。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考