Computing.Net > Forums > Programming > c++ - system() question

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

Reply to Message Icon

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:

outformat
name_of_processed_file
name_of_original_photo

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?

thanks,
BabaG



Sponsored Link
Ads by Google

Response Number 1
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
Reply:

thanks Razor2.3!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: c++ - system() question

Help with C++ SYSTEM STUFF www.computing.net/answers/programming/help-with-c-system-stuff/7052.html

Simple C program question www.computing.net/answers/programming/simple-c-program-question/18390.html

C++ system() and variables? www.computing.net/answers/programming/c-system-and-variables/11796.html