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

请教怎样判断txt文本是否换行

2012-02-28 
请问怎样判断txt文本是否换行ifstreamfilecharchintrowfile.open( test.txt )while(!file.eof()){ch

请问怎样判断txt文本是否换行
ifstream   file;
char   ch;
                int   row;
file.open( "test.txt ");
                while(!file.eof())
                {
ch   =   file.get();
                //如果换行,row增加1怎么写?
                }

[解决办法]
while(!file.eof())
{
ch = file.get();
if(ch == '\n ')row++; //如果换行,row增加1
}

热点排行