首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

while(*p++=*p2++!='\零');与while((*p++=*p2++)!='\0');//有什么区别

2012-09-03 
while(*p++*p2++!\0)与while((*p++*p2++)!\0)//有什么区别?C/C++ code#include iostreamusing

while(*p++=*p2++!='\0');与while((*p++=*p2++)!='\0');//有什么区别?

C/C++ code
#include <iostream>using namespace std;int main() {     char array[5]="abcd";    char array2[5]="efgh";    char* p =array;    char* p2 =array2;    while((*p++=*p2++)!='\0');        if((*p)=='\0')//为什么不等于'\0'?            cout<<"\0"<<endl;}


[解决办法]
1.
C/C++ code
while(*p++=*p2++!='\0');与while((*p++=*p2++)!='\0');//有什么区别//!=优先级高于=优先级,所以while(*p++=*p2++!='\0');相当于while(*p++=(*p2++!='\0')); 

热点排行