If you want basic C programming help then a Qt specific forum is not the best place to look.
If you want a text file with new line characters between lines then you should actually put a new line character in the output and use the text file write functions like fprintf() (or C++ streams).
int tt=100;
FILE *fp = NULL;
if (fp = fopen("test.txt", "a")) {
fprintf(fp, "%d\n", tt);
}
int tt=100;
FILE *fp = NULL;
if (fp = fopen("test.txt", "a")) {
fprintf(fp, "%d\n", tt);
}
To copy to clipboard, switch view to plain text mode
or using Qt:
int tt=100;
s << tt << endl;
}
int tt=100;
QFile fp("test.txt");
if (fp.open(QIODevice::Text | QIODevice::Append)) {
QTextStream s(&fp);
s << tt << endl;
}
To copy to clipboard, switch view to plain text mode
Unrelated to your question:
- Lines 4 and 5 do nothing (generate compiler warnings here)
- Line 11 will not compile as supplied, and the arguments are possibly the wrong way around.
Bookmarks