[問題]檔案的輸入
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp;
int test[NUM];
int i,j;
fp=fopen("test1.txt","w");
if(fp==NULL)
{
printf("not open file\n");
return 1;
}
else{
printf("open file\n");
}
printf("input sum\n");
for(i=0;i<NUM;i++)
{
scanf("%d",&test[i]);
}
for(j=0;j<NUM;j++)
{
fprintf(fp,"NO.%-5d%d\n",j+1,test[j]);
}
printf("write finish\n");
fclose(fp);
system("PAUSE");
return 0;
}
這是一般寫入的程式可是這是固定路徑如果我要指定到我想要的路徑
要如何撰寫?
我要讀取一個.txt檔...可是我想指定 路徑 讀取....
那個路徑可以隨意更動,要怎麼寫?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.37.164.192
→
12/03 20:32, , 1F
12/03 20:32, 1F
→
12/03 20:35, , 2F
12/03 20:35, 2F
推
12/03 20:40, , 3F
12/03 20:40, 3F
→
12/03 20:53, , 4F
12/03 20:53, 4F
→
12/03 20:55, , 5F
12/03 20:55, 5F
→
12/03 21:14, , 6F
12/03 21:14, 6F
→
12/03 21:17, , 7F
12/03 21:17, 7F
→
12/03 21:22, , 8F
12/03 21:22, 8F
推
12/03 22:40, , 9F
12/03 22:40, 9F
→
12/03 22:40, , 10F
12/03 22:40, 10F
→
12/03 23:24, , 11F
12/03 23:24, 11F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章