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.

9th Sep 2020, 7:26 PM
Sebastian Ahlborn
Sebastian Ahlborn - avatar
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; }
9th Sep 2020, 7:34 PM
RKK
RKK - avatar