What are the differences between sizeof()
, size()
, strlen()
?
In which cases I should use a certain function?
size()
function is used to return the size of the list container or the number of elements in the list container.
You can use this to find number of elements in an array.
sizeof()
is used with the data types such as int, float, char… etc it simply returns the amount of memory is allocated to that data types.
The strlen()
function in C++ returns the length of the given string. It returns the length of the null terminated byte string.