Presentation on string
-
Upload
yubarajoli77 -
Category
Technology
-
view
90 -
download
1
Transcript of Presentation on string
![Page 1: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/1.jpg)
Presentation on stringhandling
Name:- Yubraj oli
![Page 2: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/2.jpg)
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>
![Page 3: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/3.jpg)
DECLARATION OF STRINGGENERAL SYNTAX:-
Char string name[size];
For example:-Char name[20];Char address[25];
![Page 4: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/4.jpg)
INTILIALIZATION OF STRING
Char name[8]={‘p’,’r’,’o’,’g’,’r’,’a’,’m’,’\o’};
OR,Char name[8]=“program”;
![Page 5: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/5.jpg)
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.
![Page 6: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/6.jpg)
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.
![Page 7: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/7.jpg)
Strlen()This function counts the number of charater present in a string .
General form:- n=strlen(string);
![Page 8: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/8.jpg)
![Page 9: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/9.jpg)
![Page 10: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/10.jpg)
Strcat()It Joins one string at the end of another string.
General syntax:
Strcat(string1,string2);
![Page 11: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/11.jpg)
![Page 12: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/12.jpg)
![Page 13: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/13.jpg)
Strcpy()The strcpy function is used to copy one string to another.
It is also used to initialize the string.
General syntaxstrcpy(str1,str2);
![Page 14: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/14.jpg)
![Page 15: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/15.jpg)
![Page 16: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/16.jpg)
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);
![Page 17: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/17.jpg)
![Page 18: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/18.jpg)
![Page 19: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/19.jpg)
Strlwr()The function strlwr helps to convert upper case to lower case.
General syntax :strlwr(string);
![Page 20: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/20.jpg)
![Page 21: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/21.jpg)
![Page 22: Presentation on string](https://reader036.fdocuments.in/reader036/viewer/2022062503/58ae194d1a28ab7e4a8b4cd1/html5/thumbnails/22.jpg)
Any Questions?