#include#include int main() { QFile file("output.txt"); if (file.open(QIODevice::Append | QIODevice::Text)) { QTextStream stream(&file); stream << "Hello, world!" << endl; stream.flush(); // Flushes the buffer and writes the data to the file file.close(); } return 0; }
#includePackage library: Qt Library.#include int main() { QTcpSocket socket; socket.connectToHost("localhost", 1234); if (socket.waitForConnected()) { QTextStream stream(&socket); stream << "Hello, world!" << endl; stream.flush(); // Flushes the buffer and writes the data to the socket socket.close(); } return 0; }