Could also turn on C++0x support - if your compiler has support, using the switch will compile your code as is. Look:
Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
string filename;
cout<<"please enter the name you want to name your file";
cin>>filename;
cout<<"please enter the text you want to create";
cin>>s;
ofstream mfile;
mfile.open(filename);
mfile<<s;
mfile.close();
}
/*
mingw32-g++.exe -std=c++0x -Wall -g -c "C:\Documents and Settings\User\My Documents\sandbox\sandbox.cpp" -o obj\Debug\sandbox.o
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
*/
Neat right?