char s[]="12345 hello world";
string ok("test for range:\n");
string &test=ok;
for(int i=0;i<17;i++)
cout<<s[i];
cout<<endl;
revers(0,16,s);
for(int i=0;i<17;i++)
cout<<s[i];
cout<<endl;
int low,high;
low=0;
high=0;
while(high<17){
if(!isspace(s[high]))
high++;
else
{
revers(low,high-1,s) ;
high++;
low=high;
}
if(high==17)
revers(low,high-1,s);
}
void revers(int begin ,int end ,char s[]){
int i,j;
int middle=(begin+end)/2;
i=begin;
j=end;
while(i<middle)
{
char temp;
temp=s[i];
s[i]=s[j];
s[j]=temp;
i++;
j--;
}
}