+ 16
What is the strlen of a?
#include<stdio.h> #include<string.h> int main (void) { char a[20]; int x; x = strlen(a); printf("%d",x); return 0; }
12 Antworten
+ 6
It depends on where the first null happens to be in memory at runtime. Don't expect it to be the same in every run. And you should understand that strlen(a) won't necessarily stop counting at 20.
+ 14
~ swim ~ yes. It depends on the ide, output was changed
+ 10
Bandi yes. You're right. And solve it😂
+ 6
Yes the output is different in different compilers ~ swim ~
+ 3
Try this 😂😂😂
https://code.sololearn.com/coap1Y62P1s5/?ref=app
+ 2
The answer may be " 3 "
+ 2
strlen is different to sizeof, so cannot be predicted here due to uninitialised array.
+ 2
You have assigned the value of string length to a variable "x" but you haven't actually inputted anything in the character variable "a". And because there is nothing specific entered by you in the variable there is some garbage or irrational value stored in a and that is why when you print "x" which should return the string length of your character instead of returning what you think it would, it will return a not so specific and correct value because there is nothing inputted inside it
+ 1
You would get a garbage value because 'a' is a NULL string.