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
The answer for this turned out to be:
#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
int i;
for( i = 1; i < argc; i++ )
{
syscall( 10, argv[i] );
}
return 0;
}
Could anyone explain this to me, I'm having trouble understanding it. And if anyone's feeling really generous:
using the same skeleton
Write a C++ application last20 that prints the last 20 characters in a file. Use only
the Unix/Linux API in your program, do not use standard library functions.
echo 01234567890123456789 > File
echo -n Last-20-characters-is >> File
./last20 File
ast-20-characters-is
Does this involve using the tail command?!
any help much appreciated,
Dave