Hi,
I tried to use boost/thread library to write a program to read a large text
file. The program compiled but did not get the right answer. I am not sure
my usage of the library is correct. I appreciate your helps.
Here are the code:
#include <iostream>
#include <fstream>
#include <string>
#include
#include
#include
#include
//#include "stdafx.h"
boost::mutex io_mutex;
using namespace std;
void mtread(char* filename,const int stidx, const int edidx,int id) {
fstream infile;
infile.open(filename);
string line;
if (infile.good()){
for (int linenum=stidx; linenum<=edidx;linenum++) {
boost::mutex::scoped_lock lock(io_mutex);
infile.seekg(linenum,ios::beg);
getline(infile,line);
cout<