You are on page 1of 1

5b. Write a C / C++ program to emulate the unix ln command.

#include<iostream>
#include<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<<"Can't Link\n";
return 1;
}
else
{
cout<<"Files have been Linked\n";
}
return 0;
}

You might also like