首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

对于c++ getline方法跨平台的有关问题

2012-09-01 
对于c++ getline方法跨平台的问题对于windows平台,换行是\r\n,而unix平台是\r,因为把windows平台下的文件,

对于c++ getline方法跨平台的问题
对于windows平台,换行是\r\n,而unix平台是\r,因为把windows平台下的文件,放到unix下来解析就会有问题,一种很逊的解决方法


bool getline(std::ifstream &is,std::string &str){
bool b = std::getline(is,str);
std::string::size_type p = str.find_last_of('\r');
if(p != std::string::npos) str.erase(p);
return b;
}


参考:http://www.cnblogs.com/linbc/archive/2010/02/10/1667224.html


热点排行