#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
QFile in("c:\\a.txt");
if(!in.open(QIODevice::ReadOnly|QIODevice::Text)) {
cerr << "File " << argv[1] << " does not exist" << endl;
}
QFile out;
out.setFileName(argv[2]);
if (out.exists()) {
cerr << "File" << argv[2] << " already exists" << endl;
return 1;
}
if(!out.open(QIODevice::WriteOnly|QIODevice::Text)) {
cerr << "Failed to open file " << argv[2] << " for writing" << endl;
return 1;
}
while (!in.atEnd()) {
QByteArray line = in.readLine();
if (!line.trimmed().isEmpty() && !line.trimmed().startsWith('#'))
out.write(line);
}
in.close();
out.close();
return 0;
}