Thursday, May 5, 2022

Creating and writing in the file and save it too . #THEHACKERS@

 #include <fstream>

#include <iostream>

using namespace std;

 

int main () {

   char data[100];


   ofstream outfile;

   outfile.open("Hassu.txt");


   cout << "Writing to the file" << endl;

   cout << "Enter your name: "; 

   cin.getline(data, 100);


   outfile << data << endl;


   cout << "Enter your age: "; 

   cin >> data;

   cout<<" Enter your id: ";

   cin>>data;

   cout<<" Enter your code: ";

   cin>>data;

   cin.ignore();

   

   outfile << data << endl;


   outfile.close();


   ifstream infile; 

   infile.open("Hassu.txt"); 

 

   cout << "Reading from the file" << endl; 

   infile >> data; 


   cout << data << endl;

   

   infile >> data; 

   cout << data << endl; 


   infile.close();


   return 0;

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...