C 如何在乙個檔案末端新增資訊

2021-10-09 02:27:21 字數 1177 閱讀 5879

我們有的時候需要輸出乙個叫做debug的檔案, 看一下自己的****出錯了, 但是我們不會怎麼在檔案的最後新增資訊, 這樣就不能看到之前我們程式返回的資訊了, 因為程式會覆蓋之前的資訊.

今天我就教大家如何在乙個檔案末端新增資訊

我們經常使用的檔案操作就是這兩個:

1.freopen 方法

#include

#include

//freopen方法在這個標頭檔案中哦!

using

namespace std;

intmain()

2.ofstream 和 ifstream 方法

#include

#include

//ifstream 和 ofstream 方法是在這裡面

using

namespace std;

ifstream cin

("filename.in");

ofstream cout

("filename.out");

intmain()

#include

#include

//別忘了引用這個標頭檔案哦!

#include

using

namespace std;

intmain()

**樣例:

#include

#include

//別忘了引用這個標頭檔案哦!

#include

using

namespace std;

string str1 =

"123abc"

;string str2 =

;//我是水印吼吼吼~

intmain()

**執行結果:

filename.out:

123abc
好了, 今天的部落格就到這裡.

喜歡我的文章就關注我吧!

如何在 Linux 中查詢乙個檔案

對於新手而言,在 linux 中使用命令列可能會非常不方便。沒有圖形介面,很難在不同資料夾間瀏覽,找到需要的檔案。本篇教程中,我會展示如何在 linux 中查詢特定的檔案。第一步要做的是通過 ssh 連線到你的 linux 在 linux 中查詢檔案有兩種方法。一種是使用find命令,另外一種是使用...

如何在Cuyahoga中新增乙個簡單的功能模組

還需在post build event中新增以下命令 xcopy s y projectdir web as?x solutiondir web modules sample xcopy s y projectdir web gif solutiondir web modules sample xc...

如何新增乙個提醒

下面的說明適合pluto 和 cosmos,在10a1108mp之後的版本上新增乙個提醒。具體步驟如下 1,在 srv reminder type 中新增type 例如 注意,定義的鬧鐘響應完了,需要執行 srv reminder notify finish 來清除定時器。取消alarm,使用srv...