Pro text/hex editor
with Binary Templates

SweetScape Knowledgebase

KB1024: How do I define a duplicate array?

010 Editor supports the concept of a duplicate array. Basically, 010 Editor allows you to define the same variable repeatedly in a template. For example:

     int x;
     int x;
     int x;

Then the first occurrence of x can be referenced as 'x[0]' and the last as 'x[2]' (just using 'x' always refers to the last defined occurrence). This is a handy way of making arrays and is used in a number of templates. For example, the array could be printed out like this:

     Printf( "%d %d %d\n", x[0], x[1], x[2] );

This system words well for single variables, but it fails when you want to define an array of arrays:

     int y[4];
     int y[4];

The above code does not compile because it is ambiguous what y[0] refers to. The solution is to place the array inside of a struct and then the struct can be defined multiple times:

     struct MYARRAY {
        int y[4]; 
     };
 
     MYARRAY a;
     MYARRAY a;



Newsletter - Receive special offers, tips, tricks and news. Join now

010 Editor v15.0.1 is here!
What's new?



E-mail: info@sweetscape.com