+ 2

write a c programme to find the length of the string using userdefined function?

can you?

24th Apr 2018, 2:27 PM
sid
sid - avatar
3 Réponses
+ 2
A string is a char array that contains a character per array position and is null terminated ( 0 or ASCII character '\0'). So if you can not use the strlen() function of the <string.h> library you can check in a loop the char array (element by element) counting characters until you find the null character.
24th Apr 2018, 2:36 PM
J Domingo Jiménez J
J Domingo Jiménez J - avatar
+ 3
C strings are null terminated, so all you have to do is initiate a counter and loop until you reach the terminating character.
24th Apr 2018, 2:37 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Yes... Anyone that know how strings are represented in C know how write it... And you?
24th Apr 2018, 2:36 PM
KrOW
KrOW - avatar