这是有关指针移动的问题
#include<stdio.h>
main(){int i;char a[18],b[18],c[18]={"How are you!"};
char *p=a,*q=b,*x=c;
for(i=0;(*(p+i)=*(x+i))!='\0';i++);
for(i=0;(*(q+i)=*(x+i))!='\0';i++);}
问题:第一个for循环后,指针x发生了移动,那么第二个for循环中指针x应该越界了
慕粉1472527782
浏览 1280回答 3
3回答
-
asd8532
x指针一直没有动啊,x+1,x+2带来的移动效果,x是不变的,不是*x++
-
慕的地8582982
ADOEUDNRTKFNBEHYNDAWZJHXGPFWLOKAXSBYUSUFBQIYEMBEPLHXTXHIFIRBDZBQUDBEUJHKHKLVYWGJZPMJSBYCVRBKSJGWYIRYHQUDAWLBXHZOEGDFTQFJZOLBRHEUXZJTMHPNKNVACGWPLHEAEHQKNELHQOYIXTDMKFIEUSHYBQTWNDFIFWSOQNJRNJUDNQGUDOLBQGKTDFVEHPLSCMOFCMPRQEUKVYFQFBFENJZURUEAXNFVXHWMWSURALHXNQSWUDGWIRUWGJZVEHXCFCZPSNQLCSBQNKIEAWZVZIQGDTRFPLOLIYUEIFBENDZMCXIZOXBRHDGXYOLCLOEOKXTIZCMQGVSUOXAXOJZWLVRBRMCZCFCDHROKNJZBQTCYVZUYHYZCYOEUGWLIYGQMPYBIYUECYUEAXAJTWSIXZPFIJWMUXCRILNKNDMBDZWZVXAREBQGDLAQTVSJGILIXUWMPSCFBEOEBKHXHUPYPFVYUQTQQSOQGJFPRHXOQMCFIYCROYAXMIYVYHOMCCRNJZCGQSDZAQZCFCYPXNIGXUQZWLOXODXZISPYNVLURYIXAWGWMIYGTPKGWGORFIEETVLIKMPLOXOLNCZAVLARAFBDACLBQTCFIDGOYAWFOLUUPYBYODTIYPHKFBYBJMOWSDGOLNXGDLGDLGXGDZVXYCLQUCSIEACFIXXHKBFILZVSJJLUXHQSODTJNKLPYBYNPSVZJMJZCRTPFCWFUYOKZPXNWXTVQGJZIYUQHPTIYHQNPFJODZIKADFBKGWAPLVXNPSOJWSUDEBDTPEHFPXVSUIRGPGRNKNWSVRUKGRUUKTJZVEADWSOLIXHWTCGUETRGQZVRHWYPZKYNLIYXNJCKUNAURLVG
-
雪颲
你又没把值赋给x,x怎么会越界
打开App,查看更多内容