C语言编码问题2:其中P+=1,*p2!='\0' #includeint main(void){char str1[10],str2[10],str[20];char *p,*p1,*p2;int i=0;p=str;p1=str1;p2=str2;printf("字符串1是; %s\n");gets(p1);printf("字符串2是:%s\n");gets(p2);while (*p1!='\0'){*p=*p1;p+=1
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/02 14:11:28
![C语言编码问题2:其中P+=1,*p2!='\0' #includeint main(void){char str1[10],str2[10],str[20];char *p,*p1,*p2;int i=0;p=str;p1=str1;p2=str2;printf(](/uploads/image/z/3692097-9-7.jpg?t=C%E8%AF%AD%E8%A8%80%E7%BC%96%E7%A0%81%E9%97%AE%E9%A2%982%3A%E5%85%B6%E4%B8%ADP%2B%3D1%2C%2Ap2%21%3D%27%5C0%27+%23includeint+main%28void%29%7Bchar+str1%5B10%5D%2Cstr2%5B10%5D%2Cstr%5B20%5D%3Bchar+%2Ap%2C%2Ap1%2C%2Ap2%3Bint+i%3D0%3Bp%3Dstr%3Bp1%3Dstr1%3Bp2%3Dstr2%3Bprintf%28%22%E5%AD%97%E7%AC%A6%E4%B8%B21%E6%98%AF%3B+%25s%5Cn%22%29%3Bgets%28p1%29%3Bprintf%28%22%E5%AD%97%E7%AC%A6%E4%B8%B22%E6%98%AF%EF%BC%9A%25s%5Cn%22%29%3Bgets%28p2%29%3Bwhile+%28%2Ap1%21%3D%27%5C0%27%29%7B%2Ap%3D%2Ap1%3Bp%2B%3D1)
C语言编码问题2:其中P+=1,*p2!='\0' #includeint main(void){char str1[10],str2[10],str[20];char *p,*p1,*p2;int i=0;p=str;p1=str1;p2=str2;printf("字符串1是; %s\n");gets(p1);printf("字符串2是:%s\n");gets(p2);while (*p1!='\0'){*p=*p1;p+=1
C语言编码问题2:其中P+=1,*p2!='\0'
#include
int main(void)
{
char str1[10],str2[10],str[20];
char *p,*p1,*p2;
int i=0;
p=str;
p1=str1;
p2=str2;
printf("字符串1是; %s\n");
gets(p1);
printf("字符串2是:%s\n");
gets(p2);
while (*p1!='\0')
{
*p=*p1;
p+=1;
p1+=1;
i++;
}
for(; *p2!='\0';p1++,p2++,p++)
*p=*p2;
*p='\0';
printf("字符串1是:%s\n字符串2是:%s\n拼接后的字符串是;%s\n",str1,str2,str);
return 0;
}
C语言编码问题2:其中P+=1,*p2!='\0' #includeint main(void){char str1[10],str2[10],str[20];char *p,*p1,*p2;int i=0;p=str;p1=str1;p2=str2;printf("字符串1是; %s\n");gets(p1);printf("字符串2是:%s\n");gets(p2);while (*p1!='\0'){*p=*p1;p+=1
*p != '\0' 是指当字符串结束时跳出 因为字符串结尾时以'\0'结尾的
p+=1 p1+=1 都是指针往后移···