tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 C Language > Basic > String length

String length 

This example shows using strlen library function.

File Name  :  
source/C/basic/string_length.c 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
01#include<stdio.h>
02#include<conio.h>
03#include<string.h>
04 
05int main()
06{
07    char *s = "BE THE CODER";
08    printf("\nLength of string (%s) is %d", s, strlen(s));
09 
10    s = "123456";
11    printf("\nLength of string (%s) is %d", s, strlen(s));
12     
13    s = "123456789";
14    printf("\nLength of string (%s) is %d", s, strlen(s));
15     
16    getch();
17    return 0;
18}

It gives the following output,
Length of string (BE THE CODER) is 12
Length of string (123456) is 6
Length of string (123456789) is 9



 
  


  
bl  br