I'm trying to execute MS-DOS DEL
commands inside a Win32 C program, and I already know that system
and popen
can be used for this. However, the problem is that both require string literals (type const char
) for the commands, and I need something like the DOS equivalent of this Perl code (more or less, don't know if it actually works):
my $user = $ENV{'USERNAME'};
my $directory = $ENV{'HOME'};
my $files = system("dir " . $directory);
my $pattern = "s/(\d{7,8})|(\"" . $user . "\")/";
$files ~= $pattern;
system("rm " . $files);
which obviously has to use string literals for the rm
command. Is there some other subprocess function in C that allows for char arrays as arguments for process names?