C语言文件操作实现,touch命令
#include <stdio.h>#include <stdlib.h>
static void Usage(void) {
fprintf(stderr, "Usage: FileName, FileName1, FileName2, ...\n");
exit(0);}
int main(int argc, char *argv[]) {
FILE *fileopen = NULL;
const char *Mode[] = {"r", "w", "a", "r+", "w+", "a+"};
if (argc == 1) { /*
* If it is the first one, argv should be the name of the program
* itself, indicating that there is no other file name
*/
Usage();
}
for (int i = 1; i < argc; i++)
{
fopen(argv, Mode);
}
fclose(fileopen);
return 0;
}
页:
[1]