NX二次开发-修剪字符串前后的空格

 1 void TrimString(string & str)
 2 {
 3     string::size_type pos = str.find_last_not_of(' ');
 4     if (pos != string::npos)
 5     {
 6         str.erase(pos + 1);
 7         pos = str.find_first_not_of(' ');
 8         if (pos != string::npos) str.erase(0, pos);
 9     }
10     else
11     {
12         //a blank string
13         str.erase(str.begin(), str.end());
14     }
15 }

 

posted on 2021-02-04 15:56  不再低调  阅读(156)  评论(0编辑  收藏  举报