为什么以下代码的输出是“ pune”?
#include <stdio.h>
#include<conio.h>
int main()
{
char str1[]="bombay";
char str2[]="pune";
char *s1=str1,*s2=str2;
while(*s1++=*s2++);
printf("%s",str1);
printf("\n");
getch();
}
最佳答案
您只是将s2复制到s1。所以很明显,输出应该是“ pune”
关于c - 了解如何使用C语言中的指针交换两个字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26073908/