Code :
float v;
{
for ( int i =0; i<Results.localresults.size() ; i++)
{
v = Results.localresults.at(i);
char *valtoAsciidata = val.toAscii().data();
out << v << endl ;
}
}
QString filename = "textfile.txt";
QFile file(filename);
QString val;
float v;
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
for ( int i =0; i<Results.localresults.size() ; i++)
{
v = Results.localresults.at(i);
val = QString::number(v);
char *valtoAsciidata = val.toAscii().data();
QTextStream out(&file);
out << v << endl ;
}
}
To copy to clipboard, switch view to plain text mode
I have written code as above to actually write values to a text file. But it writes the values continuously . What I want is one value to be written in one single line, then the next value on the next line.
How to code in such a way that it writes one value per line ?
Bookmarks