jeudi 17 septembre 2020

How to initialize a pointer pointing to an array to null values for all index in the array

 T *newPtr = nullptr;
 T array[size] = {};
 newPtr = array;

I am trying to have a pointer point to an array of a custom size. My code above works but it starts giving me lvalue errors when I initialize to {}. I want to initialize all the indices in the array to nullptr, but I am having trouble understanding how this would work if its even possible. What is the best way to initialize and check if the values in the array are empty using a pointer?

Aucun commentaire:

Enregistrer un commentaire