Need help converting some Perl to C/C++

Discussion in 'Programming/Html' started by prof72, Nov 18, 2013.

  1. prof72

    prof72 Master Guru

    Messages:
    219
    Likes Received:
    0
    GPU:
    Gigabyte GTX 670 OC
    I have found a perl script I want to convert to C/C++.

    I had no understanding of Perl before I started this task and am steadily making progress.
    However one line is giving me real difficulty so I decided to post and ask.

    Code:
    my $dungeon_layout = {
      'Box'         => [[1,1,1],[1,0,1],[1,1,1]],
      'Cross'       => [[0,1,0],[1,1,1],[0,1,0]],
    };
    
    ..
    
    my $mask = $dungeon_layout->{$dungeon->{'dungeon_layout'}}
    my $r_x = (scalar @{ $mask } * 1.0 / $dungeon->{'n_rows'});
    
    The last line of these 2 lines I am not 100% sure what is happening.
    I think it is the size of an array $mask, but then why would you multiply that by 1.0?

    IS the below correct?

    Code:
    int r_x = ARRAYSIZE(maskArray) * 1.0 / dungeon.n_rows
    
    Thanks.

    I can post the whole .pl file if neccessary.
     

Share This Page