全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1896
推到 Plurk!
推到 Facebook!

如何讀一個txt然後將它存到另一個txt

答題得分者是:christie
quentin520
一般會員


發表:15
回覆:13
積分:5
註冊:2006-12-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-08-04 21:45:35 IP:210.60.xxx.xxx 訂閱
拜託!
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-08-05 09:09:10 IP:203.73.xxx.xxx 未訂閱
如何讀一個txt然後將它存到另一個txt
for example:

/* Program to create backup of the AUTOEXEC.BAT file */
#include
int main(void)
{
FILE *in, *out;
if ((in = fopen("\\AUTOEXEC.BAT", "rt"))
== NULL)
{
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
if ((out = fopen("\\AUTOEXEC.BAK", "wt"))
== NULL)
{
fprintf(stderr, "Cannot open output file.\n");
return 1;
}
while (!feof(in))
fputc(fgetc(in), out);
fclose(in);
fclose(out);
return 0;
}
------
What do we live for if not to make life less difficult for each other?
salo0610
高階會員


發表:42
回覆:120
積分:107
註冊:2003-02-18

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-08-05 11:04:27 IP:220.132.xxx.xxx 未訂閱

如果內容一樣!!
可以考慮直接檔案復制!!

CopyFile

The CopyFile function copies an existing file to a new file.
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);



===================引 用 christie 文 章===================
如何讀一個txt然後將它存到另一個txt
for example:

/* Program to create backup of the AUTOEXEC.BAT file */
#include
int main(void)
{
FILE *in, *out;
if ((in = fopen("\\AUTOEXEC.BAT", "rt"))
== NULL)
{
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
if ((out = fopen("\\AUTOEXEC.BAK", "wt"))
== NULL)
{
fprintf(stderr, "Cannot open output file.\n");
return 1;
}
while (!feof(in))
fputc(fgetc(in), out);
fclose(in);
fclose(out);
return 0;
}
quentin520
一般會員


發表:15
回覆:13
積分:5
註冊:2006-12-18

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-08-09 16:53:42 IP:218.32.xxx.xxx 訂閱
謝謝!
系統時間:2024-04-24 0:25:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!