remove leading and tailing spaces
| 24 | |
| 25 | // remove leading and tailing spaces |
| 26 | std::string trim_spaces(const std::string& str) { |
| 27 | const char* p = str.c_str(); |
| 28 | |
| 29 | while (*p != 0 && isspace(*p)) { |
| 30 | p++; |
| 31 | } |
| 32 | |
| 33 | size_t len = strlen(p); |
| 34 | |
| 35 | while (len > 0 && isspace(p[len - 1])) { |
| 36 | len--; |
| 37 | } |
| 38 | |
| 39 | return std::string(p, len); |
| 40 | } |
| 41 | |
| 42 | std::string erase_spaces(const std::string& str) { |
| 43 | std::string result; |