String Handling Function

String A string is an array of char values terminated by a special null character value '\0'. A null terminated string contains th...

String
A string is an array of char values terminated by a special null character value '\0'. A null terminated string contains the characters that comprise the string followed by null. Thus during execution of program the declaration must be one more than the no of elements because null character \0 is placed at the last address.
Array of string as two dimensional array of character shows size and length of string. The first dimension or size tells how many string are in array and the second dimension tells the maximum length of each string.





String Handling Function
The library  or built-in functions strlen(), strcpy(), strcat(), strcmp(), strrev(), strlwr(), strupr() etc are used for string manipulation. All the string function is defined on the header file string.h.

strlen()
This function return an integer which denotes the length of string passed. The length of string is the number of characters present in it, excluding the terminating null character.

syntax
strlen(string constant);
or
strlen(variable);

Example
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char name[40];
    int l;
    printf("Enter your name : \t");
    gets(name);
    l = strlen(name);
    printf("\nThe no of character of your name is %d", l);
    getch();
}


strcpy()
The strcpy() function copies one string to another. The function accepts two string as parameters and copies the second string character by character into the first one upto including the null character of the second string.

syntax
strcpy(destination, source);

Example
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char name[] = "Ram", s[5];
    strcpy(s,name);
    printf("%s",s);
    getch();
}


strcat()
This function concatenates two string i.e. it appends one string at the end of another. This function accepts two strings as the paramenters and stores the contents of the second string at the end of first.

syntax
strcat(string1, string2);

Example
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char a[20] = "Shyam", b[5] = "Hari";
    strcat(a,b);
    printf("\nThe output is %s", a);
    getch();
}


strcmp()
This function compares two strings to find out whether they are same or different. This function is useful for constructing and searching string as arranged into a dictionary. This function accepts two string as parameters and returns as integer whose value may be zero, negative or positive. Two strings are comparing character by character until there is mismatch or end of one string and output is given as ASCII value.

syntax
strcmp(string1, string2);

Example
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char a[] = "Ram", b[] = "Rest";
    int i;
    i = strcmp(a,b);
    printf("%d",i);
    getch();
}


strrev()
This function is used to reverse all characters in a string except null character at the end of string.

syntax
strrev(string);

Example
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char a[15] = "Xenium";
    char b[15];
    strcpy(b,a);
    strrev(b);
    printf("Real name %s and reversed name is %s",a,b);
    getch();
}


COMMENTS

Name

Accident Alert,1,AI,2,Array,1,Aurdino,1,C,2,Computer Graphics,9,Data Science,3,Dataset,1,Decoratot,1,Django,1,ESP32,1,Fixed point/iteration method,1,Greater or smaller,1,html,1,Image Processing,1,JAVA,1,Javascript,22,Machine Learning,1,Matlab,3,Numerical Method,13,OOP,1,Other,3,PHP,1,Point operation,1,Python,11,Raspberry pi,1,Recommendation System,1,Regression,1,Reservation System,1,Robotics,1,Simulation,2,sine wave,1,String Handling Function,1,Web scrap,1,Webpage,1,
ltr
item
COMPUTER PROGRAMMING: String Handling Function
String Handling Function
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9TG5PpbxxGr_nQG7LsxwjhvnlhHUwiYiOvBcNiaQ2jaXQ7kjwKUP1Zf28-OFnZGi0hzKLVvy3LfOe_csiXd-TB0l_ujLUSrdvB4pm5uNdUX5IpQHCjlAkMntOkthTUhUi9zf27uzXgxS_/s320/string.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9TG5PpbxxGr_nQG7LsxwjhvnlhHUwiYiOvBcNiaQ2jaXQ7kjwKUP1Zf28-OFnZGi0hzKLVvy3LfOe_csiXd-TB0l_ujLUSrdvB4pm5uNdUX5IpQHCjlAkMntOkthTUhUi9zf27uzXgxS_/s72-c/string.jpg
COMPUTER PROGRAMMING
https://computerprogram4ru.blogspot.com/2018/08/string-handling-function.html
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/2018/08/string-handling-function.html
true
8672391763020279633
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy