[英]How can I make a function call with filepath?
我只想使用文件路徑為“ /home/merve/merve.txt”的函數進行調用:
void GenerateUnecryptedData(const char* pathToUnencryptedFile)
{
// File structure:
int offset=0;
ofstream myfile;
myfile.open ("pathToUnencryptedFile", ios::out | ios::app | ios::binary);
// + 20 bytes of arbitrarily chosen data (offset: 0)
myfile.seekp(offset) << CD ;
// + IV (Initialization Vector) 16 bytes (offset: 20)
offset=20;
myfile.seekp(offset) << IV;
offset=36;
// + 48 bytes of Plain Text(offset: 36)
//- PLAINTEXT = ENCRYPTEDBurada herhangi birsey yaziyor olabilir
myfile.seekp(offset) << PLAINTEXT ;
}
那我怎么調用我的函數呢?
順便說一句,我不確定我的代碼是否能正常工作? 我要在函數調用后嘗試。
我只是一個初學者,所以請簡化一下!
只需將其作為變量傳遞即可。 如果用引號引起來,它將被解釋為string
文字。 我也建議使用std::string
代替char*
void GenerateUnecryptedData(std::string const pathToUnencryptedFile)
{
ofstream myFile{pathToUnencryptedFile, ios::out | ios::app | ios::binary};
}
那你就稱它為
GenerateUnecryptedData("/home/merve/merve.txt");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.