mardi 12 avril 2022

How to get whether there are elements left in array or not

int main()
{
    int arr[10000] = {1, 2, 3, 4};
    int i = 0;
    int num = 0;
    int n = 10;
    
    while(arr[i] != null){
        num = num * n + arr[i];
        i++;
    }
    
    cout << num << '\n';
    
    return 0;
}

It throws error, but i don't know how to get if there're left any elements in my array or not, but i don't want to change null with 0, because it is possible certain element to be 0.

Aucun commentaire:

Enregistrer un commentaire