Helper function for converting to C array