system() command help

command doesnt work in C++ but same command runs in prompt

Page 1 of 1

2 Replies - 1521 Views - Last Post: 28 October 2006 - 02:02 PM Rate Topic: -----

#1 mfc51  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-October 06

system() command help

Posted 28 October 2006 - 01:19 PM

im trying to continuously compare an image with itself. the command works fine when typed in the prompt, but when i run the program below, i get the output: "compare: unable to open image 'C:ob.jpg': No such file or directory. any ideas. thanks.


#include <iostream>
#include <string>

using namespace std;

int main()
{
	int a;
	
	for(a=1;a>0;a++){
	system("compare C:\rob.jpg C:\rob.jpg C:\3.bmp");
	
}}


edit: added [code] tags ~ jayman9

Is This A Good Question/Topic? 0
  • +

Replies To: system() command help

#2 BitByte  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 194
  • Joined: 09-August 06

Re: system() command help

Posted 28 October 2006 - 01:51 PM

Use two backslashes \\
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: system() command help

Posted 28 October 2006 - 02:02 PM

BitByte is correct you need to use two backslashes in order for the system to see one of them. The compiler sees the first one as an escape sequence.

system("compare C:\\rob.jpg C:\\rob.jpg C:\\3.bmp");


Was This Post Helpful? 1

Page 1 of 1