problem in calling string function
Hi,
here is my code
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
));
}
when i compile this code this error shows:
error: too few arguments to function 'std::string cmdCommand(const string&)'
cmdCommand();
^
thanks :)
Re: problem in calling string function
The compiler already told you what the problem is, no?
Cheers,
_
Re: problem in calling string function
That "return buffer.str();" on line 9 is going to make it really difficult to execute any of the code that comes after it. If you do remove it, then Google is going to be really annoyed when you recursively ping it a million or so times until your call stack overflows.
And if you still don't understand what the error is in your code, compare lines 1 and 23 and see if you can spot the difference.
Re: problem in calling string function
Your method cmdCommand(const string &command) expects a string as argument while in line 23 you call this method with cmdCommand(); so without a string argument.