我对此很新,但我正在尝试写入我在C ++中创建的目录中的.txt文件,但我有点卡住了。这就是我到目前为止所做的:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <windows.h>
using namespace std;
if ((GetFileAttributes("enc")) == INVALID_FILE_ATTRIBUTES) {
CreateDirectory("enc", 0);
CreateDirectory("enc/dir", 0);
CreateDirectory("enc/misc", 0);
}
string prompt = "CLI>";
fstream iMisc;
fstream dir;
dir.open("enc/dir/dir.txt");
iMisc.open("enc/misc/misc.txt");
//I need to read in the first line of misc.txt here if it exists
//And I must write to and create misc.txt here if it doesn't exist
cout << prompt;
system ("pause");