大家有好的方法也可以贴出来
// 字符串去前后空格
void trim_left_right(std::string &str)
{
string str_temp = str;
string::iterator new_end = remove_if(str_temp.begin(), str_temp.end(), bind2nd(equal_to
str_temp.erase(new_end, str_temp.end());
new_end = remove_if(str_temp.begin(), str_temp.end(), bind2nd(equal_to
str_temp.erase(new_end, str_temp.end());
str = str_temp;
}
下面有个牛人写的 更好:
*/
#define STR_WHITESPACE " \t\n\r\v\f"
}
eg:
FILE *srcFile = fopen("yan","r");
if ( srcFile == NULL )
{
return -1;
}
char buf[128];
for (;fgets(buf,128,srcFile) != NULL;memset(buf,'\0',128))
{
string tmp_str = trimWhiteSpace(string(buf));
if (tmp_str.size() > 0)
shield_prefixs.push_back(tmp_str);
}
return 0;
http://blog.csdn.net/yanook/article/details/7217753