Quantcast
Channel: For any string "char name[10]="test"",is strlen(name)+1 always guaranteed to be same as sizeof(name)? - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by Mike Woolf for For any string "char name[10]="test"",is...

For a declared array like char name[10], sizeof(name) is the size of the entire array, regardless of what data is stored in it. strlen(name) returns the number of characters in the array before the...

View Article



Answer by autistic for For any string "char name[10]="test"",is...

Which book are you reading? sizeof is an operator that tells you how many bytes a type (or in your case, the type of an object) occupies. strlen is a function that tells you where the first '\0'...

View Article

For any string "char name[10]="test"",is strlen(name)+1 always guaranteed to...

For a string name[],can we use strlen(name)+1 and sizeof(name)interchangeably in our code without second thought?Aren't they same?I checked about it and found out even the return type for both is...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images