|
> まず、フォルダ名を入力させてそのフォルダを開くと中にあるa〜dのファイルを
> 書き込みモードで開けるようにしたいのですが、
#include <stdio.h>
#ifdef __GNUC__
#include <unistd.h>
#else
#include <direct.h>
#endif
int main(void)
{
FILE *fp[4]; char dir[1024]; int i;
printf("フォルダ名? ");
scanf("%s", dir);
chdir(dir);
fp[0] = fopen("a", "w");
fp[1] = fopen("b", "w");
fp[2] = fopen("c", "w");
fp[3] = fopen("d", "w");
fprintf(fp[0], "aaa\n");
fprintf(fp[1], "bbb\n");
fprintf(fp[2], "ccc\n");
fprintf(fp[3], "ddd\n");
for (i = 0; i < 4; i++) fclose(fp[i]);
return 0;
}
|