1. 程式人生 > >資訊學奧林匹克競賽-複賽無腦操作攻略(檔案讀寫)

資訊學奧林匹克競賽-複賽無腦操作攻略(檔案讀寫)

功能:該程式可以在pas檔案隔壁自動新建一個test.txt檔案,並且在這個記事本檔案裡自動寫入"helloworld"字樣。

begin

assign(output,'test.txt');

rewrite(output);

write('helloworld');

close(output);

end.

功能:該程式可以在pas檔案隔壁自動尋找一個test.txt檔案,並且把這個記事本檔案裡的內容傳給一個叫s的變數。

var s:string;

begin

assign(input,'test.txt');

reset(input);

read(s);

writeln(s);

readln;

close(input);

end.