有以下程序,程序中库函数islower(ch)用以判断ch中的字母是否为小写字母:#include #include yoid fun(char p[]){int i=0;while(p[i]){if(p[i]= =' '&& islower(p[i-1]))p[i-1]=p[i-1]-'a' +'A';i++;}}int main(){char s1[ 100]="ab cd EFG!";fun(s1);printf("%s\n", s1);return 0;}
A. ad cd EFg!
B. Ab Cd EFg!
C. ab cd EFG!
D. aB cD EFG!
查看答案
阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。下面函数的功能是计算指针p所指向的字符串的长度(即实际字符个数)unsigned int MyStrlen(char *p){unsigned int len;len=0;for(;*p!=________;p++){len________;}return ________;}
阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。下面函数的功能是比较两字符串的大小,将字符串中第1个出现的不相同字符的ASCII码值之差作为比较结果返回。若第1个字符串大于第2个字符串,则返回正值;若第1个字符串小于第2个字符串,则返回负值;若两个字符串完全相同,则返回0值。int MyStrcmp(char *p1,char *p2){for(;*p1==*p2;p1++,p2++){if(*p1=='\0') return ________;}return________;}
阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。下面程序比较用户键盘输入的口令userInput与内设的口令password是否相同。若相同,则输出"Correct password!Welcome to the system..."若passwordpassword"#include #include int main(void){char password[7]="secret";char userInput[81];printf("Input Password");scanf("%s",userInput);if(________)printf("Correct password!Welcome to the system...\n");else if(________)printf("Invalid password! user inputpassword\n");return 0;}
调用strcmp函数比较字符串大小时,通常较长的字符串会较大。
A. 对
B. 错