Reputation: 37
I have written a sample c++ program...here i am using system command to call python program with an argument...
system("python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f%d.txt",tid);
/home/rpms/a3/dsp/noise_rem_python.py is a program name
/home/rpms/a3/dsp/files/p1f%d.txt
is a parameter for this program.
but I am getting error as:
"/usr/include/stdlib.h: In function ‘void* writefile(void*)’: /usr/include/stdlib.h:712: error: too many arguments to function ‘int system(const char*)’ writefile.cpp:29: error: at this point in file"
Upvotes: 0
Views: 3424
Reputation: 3030
You can also do it this way:
char command[200]; // 200 is just an example value that can hold the whole string
sprintf(command, "python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f%d.txt", tid);
system(command);
if you want to do it in the same style.
Upvotes: 2
Reputation: 477100
Say this:
#include <string>
system(("python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f" + std::to_string(tid) + ".txt").c_str());
Upvotes: 1
Reputation: 4985
look at the end of the arguments you are passing in to the function
... ,tid);
if you are trying to format a string? Do it before you use it as an argument.
Upvotes: 0