• 3545阅读
  • 1回复

关于文件的读写 [复制链接]

上一主题 下一主题
离线banyibanyi
 

只看楼主 倒序阅读 楼主  发表于: 2010-03-02
hisFile.open(QIODevice::ReadOnly);
    QTextStream readIn(&hisFile);
while(!readIn.atEnd())
    {
    readIn>>now_data.his_month;
    readIn>>now_data.his_time;
    readIn>>now_data.his_thing;

    qDebug()<<now_data.his_month;
    qDebug()<<now_data.his_time;
    qDebug()<<now_data.his_thing;
        }


我从一个文件里读文件  不知道为什么最后会多读出3个空字符串

也就是说循环多了一次,应该怎么样控制循环才好呢?
离线steinlee

只看该作者 1楼 发表于: 2010-03-02
the empty string may be return sign. You can check if the loading string is empty or zero length.
Looking for remote C/C++ and Qt 兼职
快速回复
限100 字节
 
上一个 下一个