Read This:
strncpy()
strncat()
strstr()
strlen()
Predefined
function defined in string.h .
Returns
the length of string .
Syntax: returntype
strlen(string_var_name)
#include<stdio.h>
main()
{
char ar[20]=“Arvind”;
printf(“%d”,strlen(ar));
}
strcmp()
Used
to compare two strings characterwise
syntax:
strcmp(s1,s2)
#include<stdio.h>
#include<string.h>
void
main()
{ int i;
char name[20]=“home";
char name1[20]="sweet";
i=strcmp(name,name1); // name<name1
printf("%d”,i);
}
-11
strcpy()
Defined
in string.h
Used
to copy one string to another string
Syntax:
strcpy(string1,string2)
Ex
#include<stdio.h>
#include<string.h>
void
main()
{ char name1[20];
char name2[20]=“harry”;
strcpy(name1,name2);
printf(“%s”,name1);
}
harry
strcat(
)
Also
defined in string.h
Syntax:strcat(string1,string2)
Append
string2 at the end of string1.
Ex.
#include<stdio.h>
#include<string.h>
main(
)
{int
i;
char name1[20]="home";
char name2[20]="sweet";
strcat(name2,name1);
printf("%s",name1); }
sweethome