0

In the below question I can get the str lengthif I use array for char a,but how to get length of character without using array

#include <stdio.h> #include<string.h> int main() { char a; char b[20]={'P','r','o','g','r','a','m','\0'}; printf("Enter any character \n"); scanf("%c\n", &a); printf("%d\n",strlen(a)); printf("Length of string b = %zu \n",strlen(b)); return 0; }

8th Sep 2020, 4:19 AM
s.ruthvik
s.ruthvik - avatar
3 Respuestas
0
Length of character without array is always 1. Because char can hold only 1 character.
8th Sep 2020, 4:28 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Thank you soo much I forgot the logic
8th Sep 2020, 4:52 AM
s.ruthvik
s.ruthvik - avatar