write new file..but error..

i am using slackware And G++ to compile
i tried make a file test.cpp;;
===================
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <cstring>

using namespace std;

int main(){

system("clear");
string amin;
printf("\n\tmasukan nama filenya....!!");
getline(cin,amin);

ofstream imon;
imon.open("("amin")");
if(imon.is_open()){
cout<<"file ready..!!"<<endl;

}else{
cout<<"imon teu aya"<<endl;
}

imon<<"#include <cstdio>"<<endl;
imon<<"#inlcude <iostream>"<<endl;
imon<<"#include <cstdlib>"<<endl;
imon<<"nusing namespace std;"<<endl;

imon<<"\nint main()"<<endl;
imon<<"{"<<endl;
imon<<"\nsystem(\"clear\");"<<endl;

imon<<"\nreturn 0;"<<endl;
imon<<"}"<<endl;
imon.close();
return 0;
}

=====================
result :
a file with Name ../amin
but i dont like it..
i want a file with the name input from getline(cin,char *);
how to do this problem..please.....??

sorry my english too bad..;

regards
budi.mulyana
Have you tried imon.open(amin)?
1
2
ofstream imon;
imon.open(amin.c_str());
thanks guys.....

this problem was solved with these.....
enjoy..

i want to try making complex program ....
once again
thanks for all .........

bye..
Topic archived. No new replies allowed.