Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

C++ student needs help!

Using the skeleton below

#include <unistd.h> // read/write
#include <sys/file.h> // open/close values
#include <string.h> // strlen
int main( int argc, char *argv[], char *env[] )
{
// C++ or C code
}

Write a C++ application myrm that removes (deletes) files passed as command line
argument. Use only the Unix/Linux API in your program, do not use standard library
functions.

echo > File1
./myrm File1

I've been trying for aages and not sure what the answer
is. Someone please help?!
[585 byte] By [Dave256000] at [2007-11-11 10:29:28]
# 1 Re: C++ student needs help!
char str[100];
sprintf("rm -parameters %s", argv[1]);
system(str);

... calls the unix rm command with your commandline parameter. Is this what you needed? There are nonstandard gibberish functions as well that are in the libraries, microsoft has them as well, but these you will have to look up in the man pages. You might look at the source code for RM as an example? I have no idea what these functions might be or why you would use them for any reason in modern programming.
jonnin at 2007-11-11 20:58:44 >