Created
June 9, 2010 12:56
-
-
Save metaxy/431431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtCore/QCoreApplication> | |
#include <QtDebug> | |
#include <QFile> | |
#include <QString> | |
int main(int argc, char *argv[]) | |
{ | |
QCoreApplication a(argc, argv); | |
QFile file("H:\\test.txt"); | |
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) | |
return 0; | |
while (!file.atEnd()) { | |
QByteArray line = file.readLine(); | |
QString s(line); | |
QList<QChar> list; | |
for(int i = 0; i <= 18; i++) { | |
if(i % 2 == 1) | |
list << s.at(i); | |
} | |
QString out = ""; | |
foreach(QChar c, list) { | |
out.append(c); | |
} | |
bool ok; | |
QString bin = QString::number(out.toLongLong(&ok,16)); | |
long long zahl = out.toLongLong(&ok,16); | |
int base = 2; | |
QString out2; | |
while(zahl != 0) { | |
int rest = zahl % base; | |
zahl = zahl / base; | |
out2.prepend( QString::number(rest)); | |
} | |
out += " - "; | |
/* for(int j = 1; j < 9;j++) { | |
QString a; | |
for(int i=0; i <= j;i++) { | |
a.append(list.at(i)); | |
} | |
bool ok; | |
// qDebug() << a; | |
out += QString::number(a.toLongLong(&ok,16)) + " "; | |
}*/ | |
qDebug() << out + out2; | |
//qDebug() << ok; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment