#Question about pointers to array construct

1 messages · Page 1 of 1 (latest)

frigid token
#

I have this bit of code:

    const factors = [_]?u8{
        null, //red
        null, //green
        null, //blue
    };

    const red: *?u8 = *factors[0];
    const green: *?u8 = *factors[1];
    const blue: *?u8 = *factors[2];

Is there a way to make this work? I'm getting this error:

main.zig:28:31: error: expected type 'type', found '?u8'
    const red: *?u8 = *factors[0];
                       ~~~~~~~^~~
frigid sage
#

do you want to store pointers in the array or get reference to the elements of the array?

frigid token
#

reference to elements

frigid sage
#

&factors[0]

pallid pier
#

To create a pointer use &factors[n]

frigid token
#

ohhhhh right

#

should have remembered

#

thanks