Rod Pemberton said:
Keith Thompson said:
Rod Pemberton said:
"Ralph A. Moritz" writes: [...]
system("/usr/games/fortune");
system("C:\Program Files\Winzip\wzip32.exe");
If that second one doesn't work check up on escape sequences WRT
the '\' character..
The second one does work and is correct for MS-DOS. The string
in system() passed directly to the OS's command processor
_AS_IS_. For the MS-DOS command.com command line, one does not
need to escape the backslash '\' character as you would for
printf().
Wrong. (Did you actually try it?)
I have existing code which does the same thing (which I which consulted
prior to my post). No escapes are needed and it works with multiple DOS
based compilers.
If so, the compilers in question may be providing an extension. If
they don't produce a diagnostic, they're non-conforming.
Show us a complete and self-contained C program that supports your
claim. For example:
#include <stdlib.h>
int main(void)
{
system("...");
return 0;
}
where "..." is replaced with whatever you like. Make sure it actually
works with some MS-DOS compiler (and tell us which one).
If you're able to do that, see what happens if the argument contains
one of the standard escape sequences: \a \b \f \n \r \t \v. If any of
those is interpreted as something other than an alert, backspace, form
feed, new line, carriage return, horizontal tab, or vertical tab
charater, respectively, then your compiler is broken.
Apparently not. I haven't checked the ISO spec.,
I suggest you do so.
but Harbison and
Steele agrees with me that the string from system() is passed as is
to the OS in an implementation defined manner.
You've misinterpreted Harbison and Steele. The string argument is
passed to the operating system's command processor for execution in
some implementation-defined way, but any implementation-defined
behavior occurs only after the string is passed to system(). The
evaluation of the argument expression is not affected by the fact that
it's in a call to system().
This:
"C:\Program Files\Winzip\wzip32.exe"
is not a valid C token (except possibly in a #include directive).