gman
gman

Reputation: 157

Running a cmd command in c program file

here goes the problem:

suppose if I want to run a plot.exe in cmd, I wrote the following line in cmd,

plot image.jpg

BTW I was trying in this way in my c file:

system("start plot image.jpg")

the above command start the cmd and also the plot command but the image file did not popup. There is an error command:

"image.jpg is not def"

What does it meant by? please help me out.

Upvotes: 0

Views: 7243

Answers (1)

ruakh
ruakh

Reputation: 183211

Probably the process's working directory is not the directory that contains the image. You can either specify the full path to the image:

system("plot /full/path/to/image.jpg");

or use chdir to change the working directory before running the command:

if(chdir("/full/path/to/") == -1)
    ; // TODO handle error
system("plot image.jpg");

Upvotes: 6

Related Questions