33 lines
797 B
C++
33 lines
797 B
C++
#include <QApplication>
|
|
#include <QFileDialog>
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QDebug>
|
|
#include <iostream>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
QApplication app(argc, argv);
|
|
|
|
QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Select File", "", "All Files (*.*)");
|
|
if (fileNames.isEmpty()) return 1;
|
|
|
|
QFile file(fileNames.first());
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
std::cerr << "Failed to open file" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
QTextStream in(&file);
|
|
QString line = in.readLine();
|
|
bool ok;
|
|
int number = line.toInt(&ok);
|
|
|
|
if (!ok) {
|
|
std::cerr << "Failed to read integer from file" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
std::cout << number * 2 << std::endl;
|
|
return 0;
|
|
}
|