C++ (Qt)#include <stdio.h>#include <stdlib.h> int main( void ){ char buf[512]; gets(buf); int val = atoi(buf); printf("%d", val * val); return 0;}
#include <iostream>using namespace std;int main() { int n; cin >> n; cout << n * n; return 0;}
process.start( fileExe ); Sleep(100); // 200 или еще сколько, чтобы процесс успел запуститься
if ( !process.waitForStarted() ) {
if ( !process.waitForBytesWritten( time ) ) { //бла-бла-бла}
if ( !process.waitForReadyRead( time ) ) { //бла-бла-бла}
void MainWindow::SlotRun(){ QProcess *P = new QProcess(); qDebug() << "Start"; P->setReadChannelMode(QProcess::MergedChannels); P->start(tr("cmd.exe"),QStringList() << tr("/c") << QCoreApplication::applicationDirPath()+"/StartHidden.cmd" << tr("Argument")); QString strings("String4\nString2\nString3\nString1"); P->write(strings.toLocal8Bit()); P->closeWriteChannel(); P->waitForFinished(); QTextCodec *Cp866 = QTextCodec::codecForName("IBM 866"); qDebug() << Cp866->toUnicode(P->readAllStandardOutput()); qDebug() << "Stop"; delete P;}
sortecho Result: %1
C++ (Qt)... success = CreateProcess(0, (wchar_t*)args.utf16(), 0, 0, TRUE, dwCreationFlags, environment.isEmpty() ? 0 : envlist.data(), workingDirectory.isEmpty() ? 0 : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(), &startupInfo, pid); if (!success) { // Capture the error string before we do CloseHandle below q->setErrorString(QProcess::tr("Process failed to start: %1").arg(qt_error_string())); } if (stdinChannel.pipe[0] != INVALID_Q_PIPE) { CloseHandle(stdinChannel.pipe[0]); stdinChannel.pipe[0] = INVALID_Q_PIPE; } if (stdoutChannel.pipe[1] != INVALID_Q_PIPE) { CloseHandle(stdoutChannel.pipe[1]); stdoutChannel.pipe[1] = INVALID_Q_PIPE; } if (stderrChannel.pipe[1] != INVALID_Q_PIPE) { CloseHandle(stderrChannel.pipe[1]); stderrChannel.pipe[1] = INVALID_Q_PIPE; } if (!success) { cleanup(); processError = QProcess::FailedToStart; emit q->error(processError); q->setProcessState(QProcess::NotRunning); return; } q->setProcessState(QProcess::Running);...
C++ (Qt) // give the process a chance to start ... Sleep(SLEEPMIN * 2);