Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <iostream>

#include <conio.h>
#include <iomanip>
#include <string>
#include "fstream"
using namespace std;
int main()
{
char ch='g';
int j=65;
double d=6.02;
string str1="saad";
string str2="mehmood";

ofstream outfile("fdata.txt");

outfile<<ch
<<j
<<' '
<<d
<<str1
<<str2;

cout<<"FILE WRITTEN"<<endl;
return 0;
}

#include <iostream>
#include <conio.h>
#include <iomanip>
#include <string>
#include "fstream"
using namespace std;
void main()
{
char ch;
int j;
double d;
string str1;
string str2;

ifstream infile("fdata.txt");

infile>>ch>>j>>d>>str1>>str2;
cout<<ch<<endl
<<j<<endl
<<d<<endl
<<str1<<endl
<<str2<<endl;

getche();
}

#include <iostream>
#include <conio.h> //for file I/O
#include <iomanip>
#include <string>
#include "fstream"
using namespace std;
int main()
{const int MAX =80;
char buffer[MAX];
ifstream infile("TEST.TXT");
while( !infile.eof() )
{
infile.getline(buffer, MAX);
cout<< buffer << endl;
}

getche();
}

You might also like