1.创建文件
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void create_file(char *filename)
{
if(create(filename,0755)<0)
{
printf("create file %s failure!/n",filename);
exit(EXIT_FAILURE);
}
else
{
printf("create file %s sucess!/n",filename)
}
}
int main(int argc ,char *argv[])
{
int i;
if(argc<2)
{
perror("please input the filename!!/n");
exit(EXIT_FAILURE);
}
for(i=1;i<argc;i++)
{
create_file(argv[i]); //创建文件
}
exit(EXIT_SUCCESS);
}