Start New Discussion within our Software Development Community

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.

Hint:
echo > File1
./myrm File1


I've gone through several linux api tutorials and am fairly competent with c++. I would greatly appreciate any help or advice.

Dave

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.

Hint:
echo > File1
./myrm File1


I've gone through several linux api tutorials and am fairly competent with c++. I would greatly appreciate any help or advice.

Dave

I suggest you look online for a list of system calls - probably regarding file handling - and find out which includes are needed. You can also just man the system call, under the right section, and determine it via that way (i.e man section_number system_call). Also, if you remember a part of a name of a system call that might help, try this; "man -k part_of_name*".

If you're just deleting files whose names are passed via parameters to the program, you don't have to use the (*env[]), what I'd do is use alias's so that I can compile and link with one, easy to remeber command. Or you can write a script that does everything for you, including write and compile the program since it is going to relatively small. :cool:

Good luck, LamaBot

This article has been dead for over six months. Start a new discussion instead.