Hi,
here is my code
string cmdCommand(const string &command){
fstream file("temp.txt");
file.close();
string cmd=command+ "> temp.txt";
file.open("temp.txt");
stringstream buffer;
buffer << file.rdbuf();
file.close();
return buffer.str();
try{
result= cmdCommand("ping google.com");
}
catch(const char* exc)
{
cout<<exc;
}
}
void MainWindow::on_pushButton_clicked()
{
cmdCommand();
ui
->textBrowser
->setText
(QString::fromStdString(result
));
}
string cmdCommand(const string &command){
fstream file("temp.txt");
file.close();
string cmd=command+ "> temp.txt";
file.open("temp.txt");
stringstream buffer;
buffer << file.rdbuf();
file.close();
return buffer.str();
try{
result= cmdCommand("ping google.com");
}
catch(const char* exc)
{
cout<<exc;
}
}
void MainWindow::on_pushButton_clicked()
{
cmdCommand();
ui->textBrowser->setText(QString::fromStdString(result));
}
To copy to clipboard, switch view to plain text mode
when i compile this code this error shows:
error: too few arguments to function 'std::string cmdCommand(const string&)'
cmdCommand();
^
thanks
Bookmarks