Array with char-keys

Charma Motoko_Kusanagi at web.de
Fri May 25 01:19:44 PDT 2007


thanks to all..
i have tested it...
seems to work as long as i am writing into the string, but it somehow looks like it is always overriding the same entry...

i got my class:
class VFIentry
{
	byte VFSfile;
	uint pos;
	uint size;
	byte flags;
}

and later in some code i do this:

VFIentry[char[]] VFIndex; // this is the array


byte VFSt;
char[] namet;
while(!index.eof())
{
	index.readExact(&VFSt, 1);
	index.readExact(&t, 1);
	namet.length = t;
	index.readExact(namet.ptr, t);
	VFIndex[namet] = new VFIentry; // **
	VFIndex[namet].VFSfile = VFSt;	
	index.readExact(&VFIndex[namet].flags, 1);
	index.readExact(&VFIndex[namet].pos, 4);
	index.readExact(&VFIndex[namet].size, 4);
	writefln("file: ", namet, " in VFS-File: ", VFIndex[namet].VFSfile, " pos: ", VFIndex[namet].pos, " size: ", VFIndex[namet].size);			
}
up to this point it seems to work correctly... i hope it isn't too hard to understans... i am reading a file that has informations about in which vfs (virtual file system) the files are and then the name-length, the name, and other informations...
i want to read them all into the array VFIndex so that i can later get the informations with VFIndex["file1.dat"] and VFIndex["file2.dat"] and so on...
i think my mistake is at the **-marked line but i am not sure..
anyone any idea?!?



More information about the Digitalmars-d mailing list