C language tutorial in telugu free download
Description
The C library function size_t strlen(const char *str) computes the length of the string str up to but not including the terminating null character.
Declaration
Following is the declaration for strlen() function.
size_t strlen(const char *str)
Parameters
- str — This is the string whose length is to be found.
Return Value
This function returns the length of string.
Example
The following example shows the usage of strlen() function.
#include <stdio.h> #include <string.h> int main () { char str[50]; int len; strcpy(str, "This is tutorialspoint.com"); len = strlen(str); printf("Length of |%s| is |%d|n", str, len); return(0); }
Let us compile and run the above program, this will produce the following result:
Length of |This is tutorialspoint.com| is |26|
Explanation of Program :
In the above program we have accepted the string from the user.
1
2
|
printf(“nEnter the String : “);
gets(str);
|
After that we have initialized the length variable with zero. “length” variable is used to keep track of the number of character accessed.
1
|
length = 0; // Initial Length
|
Initially length is 0. Now we are accessing very first character. If it is equal to NULL then we are terminating the loop else we are incrementing the length.
More Stories
Notice: Trying to access array offset on value of type bool in /hermes/bosnacweb05/bosnacweb05bi/b2282/ipg.jbbuidtech37209/timecomputers/wp-content/themes/enternews/inc/template-functions.php on line 601
C tutorial in telugu about Strings Part 36
Notice: Trying to access array offset on value of type bool in /hermes/bosnacweb05/bosnacweb05bi/b2282/ipg.jbbuidtech37209/timecomputers/wp-content/themes/enternews/inc/template-functions.php on line 601
How to learn c programming in telugu Strings example2 part 34
Notice: Trying to access array offset on value of type bool in /hermes/bosnacweb05/bosnacweb05bi/b2282/ipg.jbbuidtech37209/timecomputers/wp-content/themes/enternews/inc/template-functions.php on line 601
C Language in Telugu Strings exp1