www.digitalmars.com         C & C++   DMDScript  

D - Problem with File streams

reply Ryan Michel <ryan michel.com.au> writes:
I have tried both the original stream.d and the one availible at DedicateD and
have come to the same problem 
both times.  I use the following code to open a file.  It is some c++ code from
Uni I am trying to convert over.  
The text files mentioned are "\n" delimited lists of words.

import stream;

alias char[] string;

void main( char[][] args )
{
	string myFile, yourFile;
	
	myFile = "lista.txt";
	yourFile = "listb.txt";

	printf("Got through the declarations, woowoo\n\n\n");

	string[] myList, yourList;

	campItems ( myFile, myList );
	campItems ( yourFile, yourList );

	for ( int i = 0; i < myList.length; i++ )
	{
		printf ( "'%.*s' ", myList[i] );
	}
	for ( int i = 0; i < yourList.length; i++ )
	{
		printf ( "'%.*s' ", yourList[i] );
	}

	/* Have to concatenate the 2 Lists, implement the 
	unique( string[] inList ) function and then display the lists to
	the screen */
}

void campItems ( string inFile, inout string[] inList )
{
	printf("I am in the function now\n\n");
	
	File	tempFile;
	tempFile.open(inFile);
	
	printf("After file declaration and opening");

	while ( !tempFile.eof() )
	{
		inList[inList.length - 1] = tempFile.readLine();
	}
}

It never reaches the line: printf("After file declaration and opening");
Bot only that but it send the computer into a major memory leak ie. used up all
512mB of physical memory and 
then 1.3gB of virtual ram before I caught it.  Something is severly stuffed big
time here, is it just me or has 
anyone else has similar problems!  Argh!
Jun 07 2002
parent "Pavel Minayev" <evilone omen.ru> writes:
"Ryan Michel" <ryan michel.com.au> wrote in message
news:1103_1023439083 news.digitalmars.com...

 File tempFile;
 tempFile.open(inFile);
Err... and where is "tempFile = new File" ???
Jun 07 2002