执行以下程序后,输出结果为。#include#include#define N 20int main(){char str[N]="hello wang!";printf("%d\n",strlen(str));return 0;}
查看答案
执行以下程序后,若输入为abc abc输出结果为。(abc与abc之间一个空格)#include#define N 20int main(){char str1[N]="abc abc";char str2[N];int i;for(i=0;str1[i]!='\0';i++){str2[i]=str1[i];}str2[i]='\0';puts(str2);return 0;}
执行以下程序后,输出结果为。#include#define N 20int main(){char str1[N]="abc abc";char str2[N]="abcabc";int flag=0,i;for(i=0;str1[i]!='\0';i++){if(str2[i]!=str1[i]){flag=1;break;}}if(flag==0)printf("ok\n");elseprintf("error\n");return 0;}
执行以下程序后,输出结果为。#include#define N 20int main(){char str[N]="abc abc abc abc abc";int i,count=1;for(i=0;str[i]!='\0';i++){if(str[i]==' '&&str[i+1]!=' '){count++;}}printf("%d\n",count);return 0;}
执行以下程序后,输出结果为。#include#define N 20int main(){char str[N]="abcdefg abc";int i=0;while(str[i]!='\0'){i++;}printf("%d\n",i);return 0;}