why this code does not work? it does not show me output
#include <stdlib.h> #include <iostream> #include <string.h> void Sort(int *arr,int length){ int *iter=arr; char buf[12],buf1[12]; while ((iter++)< (arr+length)){ if (iter==arr || (strcmp(itoa(*iter,buf,10),itoa(*(iter-1),buf1,10))>=0)){ iter++; } else{ *iter^=*(iter+1); *(iter+1)^=*iter; *iter^=*(iter+1); iter--; } } } int main(){ int a[]={1,2,10,100,19,21,2,4,31}; int n=sizeof(a)/sizeof(int); Sort(a,n); for(int i=0;i<n;i++) std::cout<<a[i]<<" "; return 0; } please help
std::swap(*iter, *(iter+1));is a lot shorter and a lot clearer.