Posted by MindBreaker at 2:34 PM
Read our previous post
Write a
program which can create files and saved messages into then fulfilling the
following requirements.
Program
should be able to:
a. create a
file with the name specified by the user.
b Save the
file at a path defined by the user.
c Save the
message in the file given by the user.
Source code
#include <iostream>
#include <fstream>
using namespace std;
void
main()
{
char
input[50],username[20];
ofstream myfile;
cout<<"Enter
your file name and format"<<endl;
cin.getline(username,20);
myfile.open(username,ios::app);
cout<<"Type
your message here"<<endl;
cin.getline(input,20);
myfile<<"The
message is "<<input<<endl;
myfile.close();
}
Output
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.