C++ program to read some input from console and write to a FILE

//read some input as your choice until user enters new line (i.e. Enter Key) character
//write each character taken from user in a file

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    char st[30],destFilename[20];
    cout<<"Enter destination file name: ";
    cin>>destFilename;
    cout<<"Enter string:";
    cin>>st;
    ofstream out(destFilename);
    out<<st;
    out.close();
    cout<<"All characters have been saved....see in file";
    return 0;
}

No comments:

Post a Comment