Hi Guys,
Please help me in doing this.
I am trying to read a file using fstream, but my prof wants me to do the same using hash table, which i have know idea. Please tell me hw can i do the same.
The file contains huge data like the size of the block and its respective data.
Please find the code below.
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
using std::ifstream;
using std::ostream;
using std::cout;
int MAX_LENGTH = 0;
int N = 1;
class Entropy
{
public:
void readData();
void process();
// void write();
ifstream fin;
ofstream fout;
};
int main()
{
Entropy zero_order;
zero_order.readData();
}
void Entropy::readData()
{
int n;
char next;
cout << "We are about to read the data from the trace.txt";
cout<<"\n\nHow many bits do you want to read?";
cin>>n;
fin.open("trace.txt");
fout.open("dude.txt");
if(fin.fail())
{
cout<<"Opening the input file failed\n";
exit(1);
}
fin.get(next);
fout<<next;
n--;
while(n != 0)
{
fin.get(next);
fout<<next;
n--;
}
fin.close();
fout.close();
}
Cheers