What is the difference between sizeof operator and strlen operator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the difference between sizeof operator and strlen operator

17th Sep 2018, 4:14 PM
M.MANIVANNAN
M.MANIVANNAN - avatar
6 Answers
+ 2
but /0 is used to declare only the end of the string then y it consider /0 as a value..
17th Sep 2018, 4:22 PM
M.MANIVANNAN
M.MANIVANNAN - avatar
+ 3
M.MANIVANNAN \0 is used to declare end of string and hence in strlen , it is not calculated... coming back to sizeof, as variable hold that character also, size changes and it should be calculated in sizeof... check with some dummy variable of size 81 and you won't be allowed to store more than 80 characters as one is reserved for \0.... now, if you do sizeof, it's 81 as 80 characters you set and one for null character
18th Sep 2018, 1:52 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
strlen operator is used for find the string length,and sizeof operator is used for find the byte size ๐Ÿ˜Ž
24th Sep 2018, 3:28 AM
Meera
Meera - avatar
+ 1
strlen operator is used for find the string length and the size of operator of ator is they declared the operator size I mean the size of is a key word.
13th Oct 2018, 5:35 PM
Meera
Meera - avatar
0
size of shows the space required to store a specific variable's data. strlen shows how many characters are in a specific string variable, which may be any number from 0 to the allocated string length.
13th Oct 2018, 4:42 PM
Roger Greenlaw
0
The function sizeof() is a unary operator in C language and used to get the size of any type of data in bytes. The function strlen() is a predefined function in C language.This is declared in "string.h" header file.It is used to get the length of array or string. Hope you got the answer..!!๐Ÿ˜‰ Cheers๐Ÿ‘
5th Jan 2020, 12:41 PM
A.Sudheer Rajkumar