954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error listing files...

Hi,
I'm trying to write an array of linked lists to disk using c++.I'm running this program on Linux.My data structures are as follows...

A Hashtable class which holds the array of linked lists...
A linked list class which also has a writetodisk function..
An indexer class which adds entries to one of 26(one for each alphabet) entries in the array of hashtable object (the hashtable object subsequently adds this entry to a given linked list.

All my classes are working fine in adding searching etc etc except for when i get down to writing to disk..In this case I am writing a few of the linked lists of the hashtable object to disk at a time then another few to another file and so on..
eg) My hashtable has 211 linked lists i write 5 at a time to one file and so on till i have written all 211 linked lists..

I do this for all my 26 hashtable objects.. My problem is that after writing a upto around 22 of these hashtable objects my 23rd is giving problems... it writes a few of its linked lists to disk and then gives me an error ie the ofstream object is null..I have posted the code below for my write function in my hashtable class .. If anyone could give me an idea where i'm going wrong i would appreciate it...

void hashtable::createbuck()
{
int i=0;
while(i<=HSIZE/NOLL) //HSIZE=211 the no of linked lists
{ //NOLL the number of linked lists written
string no; //at a time...
string path="ht/"; //to create the path...
path=path+letter+"/"; //letter is a member fn storing which //letter the hashtable refers to
itoa(i,no); //convert i to a string
path+=no;
path+=".gig";
//cout<<"PATH: "<

crazybitez
Newbie Poster
8 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

Please put the code in [ code ] [ / code] tags... it'll be easier to read.

Where is the error about null ofstream happening?

Here?
ht[i*NOLL+j].writetofile(of); //linkedlist

cosi
Junior Poster
153 posts since Aug 2004
Reputation Points: 17
Solved Threads: 1
 


void hashtable::createbuck()
{
int i=0;
while(i<=HSIZE/NOLL) //HSIZE=211 the no of linked lists
{ //NOLL the number of linked lists written
string no; //at a time...
string path="ht/"; //to create the path...
path=path+letter+"/"; //letter is a member fn storing which //letter the hashtable refers to
itoa(i,no); //convert i to a string
path+=no;
path+=".gig";
//cout<<"PATH: "<
My error is that after writing a few linked lists to disk the ofstream object of keeps returnin null...and thus "Hash:Error creating file" keeps occuring...

crazybitez
Newbie Poster
8 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You