TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 11 May 2020

String Library Function In C Language | String Library Function In C Language In Hindi

String Library Function In C  Language

In this header file string  related  header file are include  and function definition are store in it, in this character group are include and there are different type function are available on it. C Support a large number  of string  handling function  in the standard  library String.h.

Example:

Strcat(), strcmp(), strrev(),  strupr(),  strlen(), strlwr(), strcpy().

    
download image of string function in c

Fig: String function

    1.    Strcat()

Concatenates(join) two strings

Synatx:

Strcat (str1,str2);

Program

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     a[20];
printf(“Input your name”);
strcpy(a,  “pramod”);
strcat( a,  “dwivedi”);
printf( “  ”, a);
getch();
}

Output:

Input your name
Pramoddwivedi

2.strlen()

Computes string’s length.

Syntax :

Variable name= strlen(string);

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     a1[20],  a2[20];
int len1,len2;
printf(“Input Value”);
scanf(“%c”, &a1);
scanf(“%c”, &a2);
len1=strlen(a1);
len2=strlen(a2);
printf(“  “, len1);
printf(“  ”, len2);
getch();
}

Output:

Input Value
Pramod
Dwivedi
6    7

3.strcpy()

Copies a string  to  another.

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     str2[]={dwivedi};
char   str1[20];
strcpy(str1, str2);
printf(“ “, str1);
printf(“  ”, str2);
getch();
}

Output:

Dwivedi
Dwivedi

4. strcmp()

Compare two String.

Syntax:

Variable name= strcmp(str1, str2);

Program

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int     s;
char     a1[20];
char     a2[30];
printf(“input String”);
scanf(“%c”, &a1);
scanf(“ %c”, &a2);
s=strcmp(a1,a2);
getch();
}


Output:

Input String
Pramod
Ram
9

5.strlwr()

Convert string to lowercase.

Syntax:

Strlwr(string name);


Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     a[20];
printf(“Input String”);
scanf(“%c”, &a);
strlwr(a);
printf(a);
getch();
}

Output:

Input  String
PRAMOD
pramod

6.strupr()

Converts into uppercase.


Syntax:

Strupr(string name);

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     a[20];
printf(“Input String”);
scanf(“%c”, &a);
strupr(a);
printf(a);
getch();
}


Output:

Input  String
pramod
PRAMOD

7. strrev()

Converts string to reverse .

Syntax:


Strrev(string name);

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char     a[20];
printf(“Input String”);
scanf(“%c”, &a);
strrev(a);
printf(a);
getch();
}


Output:

Pramod
domap





No comments:

Post a Comment