array compress

i need to do something like dirs in the pc. like C:\System\etc.
using arrays or something else.

thinked about:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
char ref [20][128][20];//just the elements
char ref_0[20][35];//wich element(0-19) and its name
char ref_0_0[20][35];
char ref_0_0_0[20][35];
char ref_0_0_1[20][35];
char ref_0_0_2[20][35];

//...until
char ref_0_0_19[20][35];
//then the next:
char ref_0_1_0[20][35];
char ref_0_1_1[20][35];
//...until
char ref_0_1_19[20][35];


where the can have up to 20 elements in each dir;
char ref [20][128][20];
//the [128] one is special, and thats the 'why so much?'.

i not put here because it will take too much time, but in real, the 'ref' will have depth = 6 or 7.

One more thing, each element of each reference must have a name and some informations, like, date of creation, prog that open the "thing", etc. (i thinked about havin a 'char ref_names[20][128][20]', but it will oly double the work)

at the end, it will looks like a oprational system only in DOS.

someone have any idea about makin that more objective. (if the hint will be only about declaration, say, this will help me a lot!).
Last edited on
I have no idea what all those matrices are supposed to mean, but the fastest way to do a directory structure is
1
2
3
4
5
6
7
8
struct File{
	std::string name;
	//TODO: other attributes and metadata
};

struct Directory:File{
	std::vector<File *> list;
};
they are dirs, but only variables, i dont want to create REAL dirs.

i'm still learning the language, but i know very exacly what i wnat. The problem is that i not know how to write that in C++;

it may be with something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
char ref[4][4][3];
ref[0] = "A:\\";
ref[1] = "B:\\";
ref[2] = "C:\\";
//...
ref[2][0]="dir_1";
ref[2][1]="dir_2";
ref[2][2]="arquivo_1";
//...
ref[2][0][0]="arquivo_255";
//and so on

//and i need to acess C:\dir1\arquivos_255, so:
int ref_dir_1, ref_dir_2, ref_dir_3;
ref_dir_1 = 2;
ref_dir_2 = 0;
ref_dir_3 = 0;

ref_dir[ref_dir_1][ref_dir_2][ref_dir_3];


think about a normal directory, it may have empty espace for new things, etc.
You'll definitely want to use the declaration I gave you. Your method is very wasteful and very limited. You can only have so many matrices before you run out of stack memory.

Try to understand the declarations and ask if there's something some part you don't understand. If you got to classes you should be able to figure it out, though.
Really thanks!
Topic archived. No new replies allowed.