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?!
I have this: $ echo > File1 $ echo > File2 $ ls File1 File2 myrm.c $ gcc -g -Wall -W -pedantic -o myrm myrm.c myrm.c:1:21: warning: C++ style comments are not allowed in ISO C90 myrm.c:1:21: warning: (this will be reported only once per input file) myrm.c:4: warning: unused parameter ‘env’ $ ./myrm File1 $ ls File2 myrm myrm.c $ echo > File1 $ ./myrm File1 File2 $ ls myrm myrm.c but i'm still none the wiser how I would fit that into C++ skeleton?
Quite frankly, this looks like the quite common case of some jerk not paying attention in class, expecting that he or she can get their work done, well and for free, on some forum. Review your materials regarding how to get an argument from the command line (hint: argc/argv), and how to remove or delete a file with the functions available in the Unix/Linux API. You may get some newb showoff who will write this for you, thus generating another person we have to watch out for when we're hiring. You won't get it from me.
Jerk? Not paying attention in class? You don't know me mate, I got an A for Java and I've just been introduced to C++ and linux. Thought maybe I could get some hints and tips and I've been given them. I've gone through the linux and C++. I'm aware that I need to use the unlink() function, I'll figure it out. I would retort with an insult but you're not worth it - whatever you're hiring I'm not applying for
That's certainly your prerogative. You will find that people operate on the premise that if it looks like a duck, walks like a duck, and quacks, then it's a duck. It's entirely possible that a mistake was made. One could have encountered a chicken that is a master of disguise and impersonation. One doesn't have the time to investigate all fowl to see if they are a chicken in duck's clothing; one falls back on much experience.