I found this algorithm to reverse the contents of an array-
But I really don't understand how it works. It looks as though the loop only traverses half of the array. If anyone could lend some insight I would appreciate it.Code:int len=strlen(word); for (int i=0;i<len/2;i++) { word[i]^=word[len-i-1]; word[len-i-1]^=word[i]; word[i]^=word[len-i-1]; }



1Likes
LinkBack URL
About LinkBacks


