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 );
}
programming/c-cpp/trimstring.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0