Skip to content

Instantly share code, notes, and snippets.

@opamp
Created March 29, 2013 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opamp/5271902 to your computer and use it in GitHub Desktop.
Save opamp/5271902 to your computer and use it in GitHub Desktop.
windowsで空ファイルの作り方がわからなかったので
#include<stdio.h>
#include<stdlib.h>
int mk_file(char*);
int main(int argc,char* argv[]){
int n;
if(argc <= 1){
printf("%s filename1 filename2 ....¥n",argv[0]);
return 0;
}
for(n = 0;n < argc;n++){
if(mk_file(argv[n]) == -1){
printf("ERROR::Fail to make %s¥n",argv[n]);
}
}
return 0;
}
int mk_file(char* name){
FILE* f;
if((f = fopen(name,"w")) == NULL){
return -1;
}
fclose(f);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment