C语言——创建文件

创建文件

#include <stdio.h>
int main(int argc,char *argv[]){
f(argc != 2){
    printf("param error");
    return 1;
 }else{
    FILE *fd = fopen(*(argv+1),"w+");
    if(fd != NULL){
        printf("%s is created.\n",*(argv+1));
    }
  }
  return 0;
}

编译运行:

~/Desktop/Mc$ gcc create.c -o create
~/Desktop/Mc$ ./create hello.txt
hello.txt is created.
wong@wong-computer:~/Desktop/Mc$ ls
hello.txt  

谢谢阅读。

猜你喜欢

转载自blog.csdn.net/weixin_40763897/article/details/87897660