I search for help online for a whole day, maybe 2.
I outputted strings to its ascii value to a file by using the for loops and char .at()
all these output went well, but how can i read it back from the file?
i tried qt library and native c++ (not problem in codeblocks, but i want to have gui)
I'm not sure how to use char array below because I wont know how long the string is, how many chars are there.
And in my file, its not only 1 line of code. For example, when i input
ABCD
AAAA
BBBB
my file will become
65 66 67 68
65 65 65 65
66 66 66 66
ifstream myFile("abc.txt");
while(myFile >> a >> a1 >> a2){
a = a - 1;
a = a1 - 1;
a= a2 - 1;
ui->aLine->setText(abc);
}
ifstream myFile("abc.txt");
while(myFile >> a >> a1 >> a2){
a = a - 1;
a = a1 - 1;
a= a2 - 1;
QString abc = QChar( a + a1 + a2);
ui->aLine->setText(abc);
}
To copy to clipboard, switch view to plain text mode
when i use just these codes below, it will only shows the first character of the whole strings.
And is there a way to make the abc still usable outside the loop? cause i need to set it after the loops right? and it always shows not declared.
myFile >> a
ui->aLine->setText(abc);
myFile >> a
QString abc = QChar( a );
ui->aLine->setText(abc);
To copy to clipboard, switch view to plain text mode
in >> a; // Not sure what's next. it keeps error
QFile mFile("abc.txt");
mFile.open(QIODevice::ReadOnly | QIODevice::Text);
QDataStream in(&mFile);
in >> a; // Not sure what's next. it keeps error
To copy to clipboard, switch view to plain text mode
Bookmarks