0
Should I use sizeof(...) in an C++-application?
Hi! Should I use the sizeof-operator? My opinion: no But I'm only a beginner, so I want to know what others think. Hoping for an answer, S.A.
1 Answer
+ 7
Sebastian Ahlborn why not?
it's useful like when you have to find the length of the array.(especially in C)
#include <stdio.h>
int main()
{
    int arr[] = { 1, 2, 3, 4, 7, 98, 0, 12, 35, 99, 14 };
    printf("Number of elements:%d ", sizeof(arr) / sizeof(arr[0]));
    return 0;
}