How to open a text file in a specific directory
I want to create a directory which is taken from the user(like test123) and than open a txt file in it and write some thing on that text. Here is my code. Please help me to solve this problem!!!
[tag]
Code:
#include <iostream>
#include <windows.h>
#include <string>
#include <stdio.h>
#include <fstream>
using namespace std;
int main(int argc, char * argv[])
{
string str;
LPSECURITY_ATTRIBUTES attr;
attr = NULL;
cout << "Type a Folder Name To Create.\n";
cout << "Folder=";
cin >> str;
CreateDirectory(str.c_str(), attr);
cout << "\nFolder Created!\n";
ofstream outfile;
outfile.open("c:\\str.c_str()\document1.txt", ios::out);
outfile<<"Hello!!!!....";
outfile.close();
return 0;
getchar();
getchar();
}
[/tag]