String Handling
Functions
,String Length Function - strlen
• Used to find length of the string
• Returns the number of character in a string
• Syntax:
int strlen(char s[]);
• Example:
char s[ ]=“AIT”
0 1 2
int len=strlen(s);
s A I T
printf(“Length=%d”,len);
O/P:
Length=3
, strlen: Program to find length of string using library fun
#include<stdio.h>
#include<string.h>
void main() Output:
{ Enter a string
char s[10]; Hello
int length; Length=5
clrscr();
printf(“enter a string”);
gets(s);
length=strlen(s);
printf(“Length=%d”,length);
getch();
}
Functions
,String Length Function - strlen
• Used to find length of the string
• Returns the number of character in a string
• Syntax:
int strlen(char s[]);
• Example:
char s[ ]=“AIT”
0 1 2
int len=strlen(s);
s A I T
printf(“Length=%d”,len);
O/P:
Length=3
, strlen: Program to find length of string using library fun
#include<stdio.h>
#include<string.h>
void main() Output:
{ Enter a string
char s[10]; Hello
int length; Length=5
clrscr();
printf(“enter a string”);
gets(s);
length=strlen(s);
printf(“Length=%d”,length);
getch();
}