Strange problem with system call

Martin Wiebusch marwie at gmx.net
Sat Feb 12 17:45:53 GMT 2000


Hi,
my programm creates a temporary file /tmp/mytempfile. Before exiting it
should remove the file. Up to now I did that with 

  system("rm -v /tmp/mytempfile");

and it worked. As my program grows I thought that I could later want to
change the name of the tempfile. So I defined a global variable

  const string TEMPFILE = "/tmp/mytempfile";

and changed my code to use TEMPFILE everywhere instead of direcly naming
"/tmp/mytempfile". I also tried to adjust the abovementioned line. I did
this:

  string cmd = "";

  ...

  cmd = "rm -v " + TEMPFILE;
  system(cmd.data());

For some reasons this doesnt work. Running the program I get these
errors

  sh: -c: line 1: unexpected EOF while looking for matching '"'
  sh: -c: line 2: syntax error: unexpected end of file

Has someone an idea of what's going wrong there?




More information about the KDevelop mailing list