Professional Documents
Culture Documents
University of Haripur: Khyber Pakhtunkhwa, Pakistan
University of Haripur: Khyber Pakhtunkhwa, Pakistan
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
char ch = 'x';
int j = 77;
double d = 6.25;
string s = "abeeha";
ofstream outfile("fdata.text");
outfile<< ch << j << d << s << endl;
cout<<"File written\n" ;
return 0;
}
Output
READING CODE:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
char ch ;
int j ;
double d;
string s;
ifstream infile("fdata.text");
infile>> ch >> j >> d >> s ;
cout<<"File Read\n" ;
return 0;
}