阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。下面函数的功能是计算指针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. 错
如果strcmp(s1,s2)返回的结果为0,表示字符串s1和s2不相同。
A. 对
B. 错