sorry for creating the same post,, but i forgot the

thing...

hi, i am trying to let the user create a file name and past it to the ofstream writer.open()
I am trying to keep asking for char until the user hit the enter key then fileName will be complete even though all the indexes are not filled... and past to the open() function... please help me fix this.. thank you very much.

int main()
{
ofstream writer;
char fileName[20];

cout<<"create a file name please"<<endl;

for(int i=0; i<20; i++)
{
cin>>fileName[i]

if(fileName[i]=='\n';
{
break;
}

}
writer.open(fileName);

return 0;
}

I think just replace this:

for(int i=0; i<20; i++)
{
cin>>fileName[i]

if(fileName[i]=='\n';
{
break;
}

}

with this:

cin.getline (fileName, 20, '\n');