Trim string

string trim ( const string & s ){
 
	const char* p = &s[0];
	const char* p2 = p + s.size();
 
	while ( *p == ' ' )
		p++;
	while ( p2 > p && p2[-1] == ' ' )
		p2--;
	return string ( p, p2-p );
}