C代码:makefile做文件
#include <dir.h>#include <stdio.h>
#include <string.h>
void MakeFile()
{
int i,j;
FILE *fp;
char *path;
char *NewName;
char disk[7][10] = {"C","D","E","F","G"};/*定义盘符数组*/
char *addtion = ":\\";
/* */
for (j = 0; j<5; j++)
{
path = strcat(disk[j],addtion); /* 获得盘符路径 */
chdir(path);
for (i = 0; i<5; i++)
{
char tempname[] = "XXXXXX";
system(path);
printf("%s\n",path);
NewName = mktemp(tempname);/*自动建立文件名*/
fp = fopen(NewName,"w");
fclose(fp);
}
}
}
void main()
{
MakeFile(); /*调用 MakeFile函数*/
printf("MakeFile success!\n\n");
}