Hi,im new to c++, i use Dev-C++ to compile my programs
i have little problem with ofstream function,i think you guys can help me
What program does?
Lets say my Computer name is nixon-pc.
Program displays text in cmd: "File nixon-pc.html has been created"
and than create file C:\nixon-pc.html .
Fist part works well,but i cant deal with ofstream function when it should create file C:\nixon-pc.html
Here is the source
#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;
void GetHostname() {
char ComputerName [MAX_COMPUTERNAME_LENGTH + 1];
DWORD cbComputerName = sizeof ( ComputerName );
GetComputerName ( ComputerName, &cbComputerName );
cout << "File " << ComputerName << ".html has been created" << endl;
system("pause");
}
void CreateFile() {
ofstream out("c:\\file.html");
out << "This is a short text.";
out.close();
}
int main() {
GetHostname();
CreateFile();
return 0;
}
So... everythig works fine except this ofstream out("c:\\file.html");
I need to apply variable ComputerName to this line, exam. ofstream out("c:\\",ComputerName,".html";
Something like that
Hope you guys understand me,thx for help! :)