presentation on string
TRANSCRIPT
Presentation on stringhandling
Name:- Yubraj oli
INTRODUCTION A string is an array of character terminated by a null character i.e ‘\o’
It is mainly used to store words or text.
It operates on null terminated arrays of character & requires the header <string.h>
DECLARATION OF STRINGGENERAL SYNTAX:-
Char string name[size];
For example:-Char name[20];Char address[25];
INTILIALIZATION OF STRING
Char name[8]={‘p’,’r’,’o’,’g’,’r’,’a’,’m’,’\o’};
OR,Char name[8]=“program”;
STRING HANDLING FUNCTIONWe need to manipulate string in different ways for example to find length of string , to compare two string , to convert the string etc.
The commonly used function along with their purpose:-
Function usesStrlen finds length of stringStrcpy copies a string into anotherStrcmp compares two stringStrcat appends one string at the end of
anotherStrlwr convert a string to lowercaseStrupr convert a string to uppercaseStrdup duplicates a stringStrrev reverse a string etc.
Strlen()This function counts the number of charater present in a string .
General form:- n=strlen(string);
Strcat()It Joins one string at the end of another string.
General syntax:
Strcat(string1,string2);
Strcpy()The strcpy function is used to copy one string to another.
It is also used to initialize the string.
General syntaxstrcpy(str1,str2);
Strcmp()The strcmp function compare two strings.
It assign the value zero if the both strings are equal.
It assign positive value if first string is greater and negative value if last string is greater.
General syntax:
c=strcmp(string1,string2);
Strlwr()The function strlwr helps to convert upper case to lower case.
General syntax :strlwr(string);
Any Questions?