string myStr = "Monthly Ecosystem NPP = 0.360591 tDM/ha month";
echo $myStr | awk '{ print $5 }'
123456789101112131415
string myStr = "Monthly Ecosystem NPP = 0.360591 tDM/ha month"; stringstream ss( myStr ); vector<string> v; string tok; while(1) { ss >> tok; if( !ss.good() ) break; v.push_back( tok ); } string res = v.size() > 4 ? v[4] : ""; cout << res << endl;
12345678
string myStr = "Monthly Ecosystem NPP = 0.360591 tDM/ha month"; istringstream tokenizer(myStr); string tok; for(k=0; k<5; k++) getline(tokenizer, tok, ' '); cout << tok << endl;