How To Use String Function Explain Briefly Details |
How To Use String Function Explain Briefly Details
String: A String is a collection of characters. C Language is not supported String data types. It can be used String char data types. String used single quotes and Double quotes.
The string can be stored single dimensional character array. There are many predefined String functions in c Language.
C Language String index can be started 0 and String terminate null character('\0').
The string can be used in C Language predefined (string. h) header file.
Important Some Others Programming Language String
👉C++ String Function
👉Java String Function
👉Python String Function
Examples
char s='icoderweb'('i',' c ','o',' d ',' e ',' r ',' w ',' e ',' b ','\0')
char s="icoderweb"
String Function Details in C Language
strcpy(s1,s2): String strcpy function can be used to copy the string here-string s2 is copied into string s1.
strcat(s1,s2): String function strcat can be used to add two strings here-string s2 concatenates at the end of string s1.
strcmp(s1,s2):String function strcmp can be used to compare two string.
strcmp string function returns 0 if string s1 and string s2 are the same.
strrev(s): String function strrev function can be used to reverse the string.
strip(s): A string function strip can be used to convert all the characters into the upper alphabet.
straw(s): String function straw can be used to convert all the characters into the lower alphabet.
strcmpi(s1,s2): The string function can be used to compare two strings.
but it ignores the case-sensitivity means 'x's and 'X' are treated as the same.
strcpy(s1,s2): String strcpy function can be used to copy the string here-string s2 is copied into string s1.
strcat(s1,s2): String function strcat can be used to add two strings here-string s2 concatenates at the end of string s1.
strcmp(s1,s2):String function strcmp can be used to compare two string.
strcmp string function returns 0 if string s1 and string s2 are the same.
strrev(s): String function strrev function can be used to reverse the string.
strip(s): A string function strip can be used to convert all the characters into the upper alphabet.
straw(s): String function straw can be used to convert all the characters into the lower alphabet.
strcmpi(s1,s2): The string function can be used to compare two strings.
but it ignores the case-sensitivity means 'x's and 'X' are treated as the same.
How To Create String in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[200]="icoderweb";
char s2[200]='icoderweb';
printf("Website Name:%s",s1);
printf("Website Name:%s",s2);
return 0;
}
*****OUTPUT*****
Website Name:icoderweb
Website Name:icoderweb
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[200]="icoderweb";
char s2[200]='icoderweb';
printf("Website Name:%s",s1);
printf("Website Name:%s",s2);
return 0;
}
*****OUTPUT*****
Website Name:icoderweb
Website Name:icoderweb
How To Use String len Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("String Lenght:%d",strlen(s));
return 0;
}
*****OUTPUT*****
String Lenght:9
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("String Lenght:%d",strlen(s));
return 0;
}
*****OUTPUT*****
String Lenght:9
How To Use String strcpy Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[100]="Python";
char s2[100]="Java"
strcpy(s1,s2);
printf("Copy String Name:%s",s1);
return 0;
}
*****OUTPUT*****
Copy String Name:Java
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[100]="Python";
char s2[100]="Java"
strcpy(s1,s2);
printf("Copy String Name:%s",s1);
return 0;
}
*****OUTPUT*****
Copy String Name:Java
How To Use String strcmp Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char user1[100]="icoderweb";
char pass1[100]="12345";
char user2[100];
char pass2[100];
printf("Enter Username:\n");
gets(user2);
printf("Enter Password:\n");
gets(pass2);
if(strcmp(user1,user2)==0&&strcmp(pass1,pass2)==0)
printf("Login Successfully");
else
printf("Wrong username or password");
}
*****OUTPUT*****
Enter Username:icoderweb
Enter Password:12345
Login Successfully
#include<stdio.h>
*****OUTPUT*****
Enter Username:icoderweb
Enter Password:12345
Login Successfully
How To Use String strrev Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("Reverse String Name:%s",strrev(s));
return 0;
}
*****OUTPUT*****
Reverse String Name:bewredoci
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("Reverse String Name:%s",strrev(s));
return 0;
}
*****OUTPUT*****
Reverse String Name:bewredoci
How To Use String stripe Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("Uper String Name:%s",strupr(s));
return 0;
}
*****OUTPUT*****
Uper String Name:ICODERWEB
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="icoderweb";
printf("Uper String Name:%s",strupr(s));
return 0;
}
*****OUTPUT*****
Uper String Name:ICODERWEB
How To Use String straw Function in C Language?
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="ICODERWEB";
printf("Lower String Name:%s",strlwr(s));
return 0;
}
*****OUTPUT*****
Lower String Name:icoderweb
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s[100]="ICODERWEB";
printf("Lower String Name:%s",strlwr(s));
return 0;
}
*****OUTPUT*****
Lower String Name:icoderweb