So i have 3 codes here,
in first one i haven't initialized the string ! and strlen shows "3" in ans
in 2nd one i initialized it with 3 char and still the same ans "3"
in 3rd i initialized it with 4 char and output is "4"
Sorry guys, if it was too obvious but i am new and so confused why it shows "3" in output in first code.
//1st
#include<stdio.h>
#include<string.h>
int main()
{
char y[20];
printf("%d",strlen(y));
return 0;
}
//2nd
#include<stdio.h>
#include<string.h>
int main()
{
char y[20]="yas";
printf("%d",strlen(y));
return 0;
}
//3rd
#include<stdio.h>
#include<string.h>
int main()
{
char y[20]="asds";
printf("%d",strlen(y));
return 0;
}