其中的 *p2=*p1; *p2='\0'; 作用是什么?#include "stdafx.h"#includeusing namespace std;int _tmain(int argc,_TCHAR* argv[]){\x05char str1[]="i love china!",str2[20],*p1,*p2;\x05p1=str1;p2=str2;for(;*p1!='\0';p1++,p2++)\x05\x05*p2=*p1;\x05*p2='\0'

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 17:27:04
其中的 *p2=*p1; *p2='\0'; 作用是什么?#include

其中的 *p2=*p1; *p2='\0'; 作用是什么?#include "stdafx.h"#includeusing namespace std;int _tmain(int argc,_TCHAR* argv[]){\x05char str1[]="i love china!",str2[20],*p1,*p2;\x05p1=str1;p2=str2;for(;*p1!='\0';p1++,p2++)\x05\x05*p2=*p1;\x05*p2='\0'
其中的 *p2=*p1; *p2='\0'; 作用是什么?
#include "stdafx.h"
#include
using namespace std;
int _tmain(int argc,_TCHAR* argv[])
{
\x05char str1[]="i love china!",str2[20],*p1,*p2;
\x05p1=str1;p2=str2;
for(;*p1!='\0';p1++,p2++)
\x05\x05*p2=*p1;
\x05*p2='\0';
\x05p1=str1;p2=str2;
\x05cout

其中的 *p2=*p1; *p2='\0'; 作用是什么?#include "stdafx.h"#includeusing namespace std;int _tmain(int argc,_TCHAR* argv[]){\x05char str1[]="i love china!",str2[20],*p1,*p2;\x05p1=str1;p2=str2;for(;*p1!='\0';p1++,p2++)\x05\x05*p2=*p1;\x05*p2='\0'
*p2=*p1; :
把str1[](*p1指向str1[])中的相应位上的字符赋值给str2(*p2指向str2[])
*p2='\0':
因为经过(p2++)此时*p2的值指向str2的末尾
'\0'标记str2结束,就像句号一样,是一位字符串数组更规范