How to use sizeof | SoloLearn: Learn to code for FREE!

+1

How to use sizeof

10/20/2016 12:39:17 PM

MUHAMMAD ILHAM

4 Answers

New Answer

+5

sizeof() gives you the size of a data type or variable, in bytes. cout << sizeof(int) << endl; int ans = 42; cout << sizeof(ans) << endl; Example of use: get the length (= number of elements) of an array: int arr[10] = {0}; int len = sizeof(arr)/sizeof(arr[0]);

+1

thanks jishnu

0

Cout<<Sizeof(x); OR i=sizeof(x); where x is a variable or constant

0

Welcome man