rafilename\n”);Exit(0);}If(in=fopen(argv[1],”r”))==NULL{Printf(“cannitopenoutfile\n”);Exit(0);}If(out=fopen(argv[2],”w”))==NULL{Prntf(“cannotopenoutfile”);Exit(0);}While(!feof(in))fputc(in),out);Fclose(in);Fclose(out);}【运行命令】#gcc–otestcopy.c#./testfile1.cfile2.c9(2)编写LinuxC程序,列出stu2主目录中的文件信息,并将其中saturday.txt文件的权限设置为文件所有者可读可写、同组用户只读、其他用户无权限。【源程序】#include<sys/types.h>#include<dirent.h>#include<stdio.h>#include<crrno.h>Intmain(intargc,char*argv[]){DIR*dp;Structdirent*dirp;Intn=0;If(arge!=2){Printf(“asignleargementisrequired”);Exit(0);}If(dp=opendir(argv[1])==NULL){Printf(“cannotopen%s”,args[1]);Exit(0);}While(((dirp=readdir(dp))!=NULL)&&(n<=50)){If(n%1==0)printf(“”);N++;Printf(“%10s\n”,dirp->d_name);}System(“chmod640/home/stu2/text/dir1/Saturday.txt”)}10【运行命令】#gcc–otestlist.c#./test.home/stu2