Presentation on string

22
Presentation on string handling Name:- Yubraj oli

Transcript of Presentation on string

Page 1: Presentation on string

Presentation on stringhandling

Name:- Yubraj oli

Page 2: Presentation on string

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

DECLARATION OF STRINGGENERAL SYNTAX:-

Char string name[size];

For example:-Char name[20];Char address[25];

Page 4: Presentation on string

INTILIALIZATION OF STRING

Char name[8]={‘p’,’r’,’o’,’g’,’r’,’a’,’m’,’\o’};

OR,Char name[8]=“program”;

Page 5: Presentation on string

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

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

Strlen()This function counts the number of charater present in a string .

General form:- n=strlen(string);

Page 8: Presentation on string
Page 9: Presentation on string
Page 10: Presentation on string

Strcat()It Joins one string at the end of another string.

General syntax:

Strcat(string1,string2);

Page 11: Presentation on string
Page 12: Presentation on string
Page 13: Presentation on string

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
Page 15: Presentation on string
Page 16: Presentation on string

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
Page 18: Presentation on string
Page 19: Presentation on string

Strlwr()The function strlwr helps to convert upper case to lower case.

General syntax :strlwr(string);

Page 20: Presentation on string
Page 21: Presentation on string
Page 22: Presentation on string

Any Questions?