//it is a function to take file name and create it.
void createfile(string filename)
{
ofstream file;
file.open(filename,ios::out);
if(file.fail())
{
cout<<"file is failed"<<endl;
}
else
{
cout<<"file is opened"<<endl;
}
}
//it is a function which takes name of file and display it's content.
void displaycontent(string name)
{
ifstream file;
file.open(name);
string y;
while(!file.eof())
{
getline(file,y);
cout<<y<<endl;
}
}
How can I display the content of the file that I already created in the first function?
int main()
{
string filename;
cin>>filename;
createfile(filename);
displaycontent(filename);
return 0;
}