Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
c++ - system() question
Name: BabaG Date: May 24, 2008 at 21:34:41 Pacific OS: mandriva 2007.1 CPU/Ram: p4 Product: self
Comment:
pretty much finished getting my little app to run and have a question about the system() command.
i'm using a command line app called nconvert to process photos. i use a command similar to this from the command line: [code] nconvert -out outformat -o name_of_processed_file name_of_original_photo [/code] there are three variables i use in the command line scripting i have:
i tried this to get system() to execute nconvert but had a problem with the variables: [code] system("nconvert -o outformat -o name_of_processed_file name_of_original_photo") [/code] i assume the quotation marks around the nconvert command are the source of the problem.
how do i use system() with variables for the parameters of the command line app?
Name: BabaG Date: May 24, 2008 at 22:42:20 Pacific
Reply:
got a reply elsewhere suggesting making a big string and using that within the system() command. just tried it and got an error. i declared: [code] string nconvert_param = "nconvert -out " + outformat + " -o " + name_of_processed_file + " " + name_of_original_photo [/code] which i can cout to the screen and prints just as it should. compiling, however, gives an error about not being able to convert 'std::string' to 'const char*' for the line in my code: [code] system( nconvert_param ); [/code] tried declaring string nconvert_param' as 'const char nconvert_param' but that produced a different error.
what did i get wrong here?
thanks again, BabaG
0
Response Number 2
Name: Razor2.3 Date: May 25, 2008 at 01:05:49 Pacific
Reply:
what did i get wrong here? Make it a string, then say
system(nconvert_param.c_str());
0
Response Number 3
Name: BabaG Date: May 26, 2008 at 13:17:34 Pacific
Summary: If you embed your C executable in a script , e.g. a batch, you can check the return code to keep track of program execution; see the following Cprog /T HostName if not errorlevel 1 echo Connection es...
Summary: First, to answer the question about how to get back to the menu, add this code to your main. I've put *** at the start of lines that I've added, so you'll need to remove the ***: int main() { int opt...