Friday, May 3, 2019

SS 12 - C++ EMULATE UNIX ln COMMAND

12. Write a C++ program to emulate the Unix ln command

lab12.cpp PROGRAM

#include<iostream>
#inculde<unistd.h>

int main(int argc, char* argv[])
{
using namespace std;
if(argc!=3)
{
cout<<"Usage ./a.out sourcefile destination file\n";
return 0;
}
if(link(argv[1],argv[2])==-1)
{
cout<<"cant link\n";
return 1;
}
else
{
cout<<"Files have been Linked\n";
}
return 0;
}

OUTPUT :( click on image to zoom )


No comments:

Post a Comment