bambooflow Note

ファイル読み込み

最終更新:

bambooflow

- view
メンバー限定 登録/ログイン

ファイル読み込み


#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <iostream>
 
int main( int argc, char *argv[] )
{
    QFile f( "file.txt" );
 
    if (f.open(IO_ReadOnly)) {
        QTextStream t( &f );
        int n = 1;
        while (!t.eof()) {
            QString str = t.readLine();
            std::cout << n++ << ": " << str.local8Bit() << std::endl;
        }
        f.close();
    }
    return 0;
}
 
記事メニュー
ウィキ募集バナー