#include <stdio.h> #include <dirent.h> main(int argc, char **argv) { DIR *dp; struct dirent *link; dp = opendir(argv[1]); while ((link = readdir(dp))!=O) printf("%s\n", link->d_name); closedir(dp); }
echo -n "enter name: " read name stty -echo echo -n "enter password: " read password stty echo echo echo name: $name echo password: $password
main(argc, argv) if argc!=3 give error and usage message and exit if argv[i] or argv[2] outside current directory i.e. if they contain a "/", give error and exit if argvEl] not in current directory give error and exit link(argv[1], argv[2]) unlink(argv[1])
Your C solution should follow this basic pattern. Try to make it as bullet proof as possible by trying to deal with as many error conditions as you can find, including checking error returns from system calls.