Hi, am trying to Write a C++ program to create a data file with several attributes. Accept n person’s information and display the same.
So far this is what I have tried to do. My chaalenge is how to read the command line ipnut from the user to the file
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile ("Data_file2.txt");
if (myfile.is_open())
{
myfile << "S.No:.\t\t";
myfile << "Name:.\t\t";
myfile << "Age:\t\t";
myfile.close();
}
else cout << "Unable to open file";
cout<< "Enter the SNo:"
cin<<
ifstream OpenFile("Data_file2.txt");
char ch;
while(!OpenFile.eof())
{
OpenFile.get(ch);
cout << ch;
}
OpenFile.close();
system("PAUSE");
return 0;
}
Can someone solve my puzzle?