I have a *.dat
file with one string - localhost
a try to read this string and set host name
QFile file("file.dat");
if (file.open(QFile::ReadOnly)) {
char buf[1024];
qint64 lineLength = file.readLine(buf, sizeof(buf));
QDebug() << buf;
if (lineLength != -1) {
db.setHostName(buf);
}
}
I expected result of QDebug
is: localhost
, but I see a "localhost
, with one quote.
Also setHostName
doesn't work because of the excess symbol - quote.
Why does the quote appear?