#include #include using namespace std; // ------------------------------------------------------------------------ string int2str( int i ) { char buff[12]; sprintf( buff, "%d", i ); return( string(buff) ); } // ------------------------------------------------------------------------ int str2int( string a ) { char tmp[12]; strcpy( tmp, a.c_str() ); return( atoi( tmp ) ); } // ------------------------------------------------------------------------ string strip( string w ) { int i, s1 = 0, s2; bool hit; string x; // empty string if( w.empty() == true ) return( w ); // string filled with spaces for( i = 0; i < w.length(); i++ ) { if( w[i] != ' ' ) { //cout << "YES - " << w[i] << "
"; hit = true; } } if( hit == false ) return( string("") ); x = " "; x += w; x += " "; hit = false; for( i = 0; i < x.length(); i++ ) { //if( w[i] != ' ' ) s2 = i; //cout << "-->" << w[i] << "<--
"; if( hit == false && x[i] != ' ' ) { hit = true; s1 = i; } if( hit == true && x[i] != ' ' ) s2 = i; } //cout << s1 << endl << s2 << endl << w.substr(s1,(s2-s1)) << endl;*/ //cout << s1 << "
" << s2 << "
"; return( x.substr(s1,(s2-s1)+1) ); }