+ 3

Length Of The Input Of Char .

I want to know the length of char in an input. Just like refering to the length of a string input as "str.length" in a for loop.

27th Dec 2019, 11:12 AM
code0rdie
code0rdie - avatar
9 Answers
+ 10
Char is intended to store only one character... so length is one... but if you are referring to char array like char ch[20], then the size is the 20... which represents 20 characters in the char array
27th Dec 2019, 11:17 AM
MCGAmedCoder gamerArtist
MCGAmedCoder gamerArtist - avatar
+ 10
you also have strlen function. you need to include string.h to use it
27th Dec 2019, 1:05 PM
notqueued
notqueued - avatar
+ 4
Okay but in can the user inputs 12 characters instead of the 20 how can i get the length value
27th Dec 2019, 11:23 AM
code0rdie
code0rdie - avatar
+ 4
or I will have to create a seperate class for that??
27th Dec 2019, 11:23 AM
code0rdie
code0rdie - avatar
+ 4
Thanks EveryBody. I have the answer now
27th Dec 2019, 1:23 PM
code0rdie
code0rdie - avatar
+ 3
Even in strings, length is the count of characters in that string. So for a character array you can use a simple for loop to find out the result.
27th Dec 2019, 11:21 AM
Avinesh
Avinesh - avatar
27th Dec 2019, 11:33 AM
Avinesh
Avinesh - avatar
0
1 byte
1st Apr 2020, 12:54 PM
Yaswanth K