在目录中创建并写入几个级别的文本文件

时间:2013-01-29 16:36:07

标签: c++ windows directory

我对此很新,但我正在尝试写入我在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");

0 个答案:

没有答案