SlideShare a Scribd company logo
1 of 11
Name:- Dhanraj Vaghela
Branch:- Mechanical (2nd
sem)
Enroll. No.:- 140990119060
From the desk of Dhanraj from SRICT
Strings
A special kind of array is an array of characters
ending in the null character 0 called string
arrays
A string is declared as an array of characters
char s[10]
char p[30]
When declaring a string don’t forget to leave a
space for the null character which is also known
as the string terminator character
From the desk of Dhanraj from SRICT
String storage
•These functions with formate specifiers %c &%s can be used for input & output
of charactors and strings.
Examples :-
Scanf(“%c”,&colour); // reading character
Scanf(“%s”,colour); // reading string
Scanf(“%c”,colour); // writing character
Scanf(“%c”,colour); // writing string
From the desk of Dhanraj from SRICT
Strlen(s1) :- returns the length of the string s1 excluding the
null character.
Strlwr(s1):- converts the string s1 to lower case.
Strcat(s1,s2):- appends a copy of string s2 to the end of s1
and terminates s1 with a null and returns s1.
Strcpy(s1,s2):- copies the srring s2 into string s1 ,modifying
the string s1.
Strcmpi(s1,s2):- compares s1 &s2 ignoring the cas and
returns similler result as strcmp.
Strupr(s1):-converts the string s1 to uppercase.
Strchr(s1,c):-returns a pointer to the first occurrence of the
character c in string s1.
Strstr(s1,s2):- returns a pointer to the first occurrence of the
string s1 in string s2.
Strrev(s1):- returns the reverse string of string s1.From the desk of Dhanraj from SRICT
Four main operations on strings
strcpy - copy one string into another
strcat - append one string onto the right side of the
other
strcmp – compare alphabetic order of two strings
strlen – return the length of a string
From the desk of Dhanraj from SRICT
strcpy
strcpy(destinationstring, sourcestring)
Copies sourcestring into destinationstring
For example
strcpy(str, “hello world”); assigns “hello world” to the
string str
From the desk of Dhanraj from SRICT
strcat
strcat(destinationstring, sourcestring)
appends sourcestring to right hand side of
destinationstring
For example if str had value “a big ”
strcat(str, “hello world”); appends “hello world” to
the string “a big ” to get
“ a big hello world”
From the desk of Dhanraj from SRICT
strcmp
strcmp(stringa, stringb)
Compares stringa and stringb alphabetically
Returns a negative value if stringa precedes
stringb alphabetically
Returns a positive value if stringb precedes
stringa alphabetically
Returns 0 if they are equal
Note lowercase characters are greater than
Uppercase
From the desk of Dhanraj from SRICT
strlen
strlen(str) returns length of string excluding null
character
strlen(“tttt”) = 4 not 5 since 0 not counted
From the desk of Dhanraj from SRICT
Input output functions of characters and
strings
getchar() reads a character from the screen in a non-
interactive environment
getche() like getchar() except interactive
putchar(int ch) outputs a character to screen
gets(str) gets a string from the keyboard
puts(str) outputs string to screen
From the desk of Dhanraj from SRICT
From the desk of Dhanraj from SRICT

More Related Content

What's hot (20)

String in c programming
String in c programmingString in c programming
String in c programming
 
Strinng Classes in c++
Strinng Classes in c++Strinng Classes in c++
Strinng Classes in c++
 
Strings
StringsStrings
Strings
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Strings
StringsStrings
Strings
 
Matlab quickref
Matlab quickrefMatlab quickref
Matlab quickref
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
Array and string
Array and stringArray and string
Array and string
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Functional programming with_scala
Functional programming with_scalaFunctional programming with_scala
Functional programming with_scala
 
14 arrays
14 arrays14 arrays
14 arrays
 
14 strings
14 strings14 strings
14 strings
 
Array &strings
Array &stringsArray &strings
Array &strings
 
Dependent Types with Idris
Dependent Types with IdrisDependent Types with Idris
Dependent Types with Idris
 
Strings in programming tutorial.
Strings  in programming tutorial.Strings  in programming tutorial.
Strings in programming tutorial.
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
Strings
StringsStrings
Strings
 

Viewers also liked

demostratre trust behavior
demostratre trust behaviordemostratre trust behavior
demostratre trust behaviorDhanraj Vaghela
 
102總局窳陋成果1208
102總局窳陋成果1208102總局窳陋成果1208
102總局窳陋成果1208TA-CHING LIANG
 
book review i,m ok you,re ok
book review i,m ok you,re okbook review i,m ok you,re ok
book review i,m ok you,re okDhanraj Vaghela
 
Animal Health Industry India 2014
Animal Health Industry India 2014 Animal Health Industry India 2014
Animal Health Industry India 2014 Dr. Sandeep Juneja
 
defining purpose of presentation
defining purpose of presentationdefining purpose of presentation
defining purpose of presentationDhanraj Vaghela
 
Windflower Hill Spa resort, Kerala
Windflower Hill Spa resort, KeralaWindflower Hill Spa resort, Kerala
Windflower Hill Spa resort, KeralaAbhiniti Garg
 
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed Industry
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed IndustryAnimal Feed Industry in India / Livestock Feed Industry / Poultry Feed Industry
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed IndustryDr. Sandeep Juneja
 
New Pharma Market Reality - Predictive Analytics is the Solution
New Pharma Market Reality - Predictive Analytics is the SolutionNew Pharma Market Reality - Predictive Analytics is the Solution
New Pharma Market Reality - Predictive Analytics is the SolutionDr. Sandeep Juneja
 

Viewers also liked (16)

Animal feedi industry_india
Animal feedi industry_indiaAnimal feedi industry_india
Animal feedi industry_india
 
demostratre trust behavior
demostratre trust behaviordemostratre trust behavior
demostratre trust behavior
 
102總局窳陋成果1208
102總局窳陋成果1208102總局窳陋成果1208
102總局窳陋成果1208
 
book review i,m ok you,re ok
book review i,m ok you,re okbook review i,m ok you,re ok
book review i,m ok you,re ok
 
Market Research On DOVE.
Market Research On DOVE.Market Research On DOVE.
Market Research On DOVE.
 
isomorphism
 isomorphism isomorphism
isomorphism
 
Magazine proposal V2
Magazine proposal V2Magazine proposal V2
Magazine proposal V2
 
Magazine proposal
Magazine proposalMagazine proposal
Magazine proposal
 
calculus Ppt
calculus Pptcalculus Ppt
calculus Ppt
 
ultracapacitor
ultracapacitorultracapacitor
ultracapacitor
 
Animal Health Industry India 2014
Animal Health Industry India 2014 Animal Health Industry India 2014
Animal Health Industry India 2014
 
Magazine proposal v2
Magazine proposal v2Magazine proposal v2
Magazine proposal v2
 
defining purpose of presentation
defining purpose of presentationdefining purpose of presentation
defining purpose of presentation
 
Windflower Hill Spa resort, Kerala
Windflower Hill Spa resort, KeralaWindflower Hill Spa resort, Kerala
Windflower Hill Spa resort, Kerala
 
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed Industry
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed IndustryAnimal Feed Industry in India / Livestock Feed Industry / Poultry Feed Industry
Animal Feed Industry in India / Livestock Feed Industry / Poultry Feed Industry
 
New Pharma Market Reality - Predictive Analytics is the Solution
New Pharma Market Reality - Predictive Analytics is the SolutionNew Pharma Market Reality - Predictive Analytics is the Solution
New Pharma Market Reality - Predictive Analytics is the Solution
 

Similar to string (20)

Strings
StringsStrings
Strings
 
String & its application
String & its applicationString & its application
String & its application
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
 
Implementation Of String Functions In C
Implementation Of String Functions In CImplementation Of String Functions In C
Implementation Of String Functions In C
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
Strings CPU GTU
Strings CPU GTUStrings CPU GTU
Strings CPU GTU
 
string in C
string in Cstring in C
string in C
 
Strings part2
Strings part2Strings part2
Strings part2
 
C string
C stringC string
C string
 
Chap 8(strings)
Chap 8(strings)Chap 8(strings)
Chap 8(strings)
 
Python data handling
Python data handlingPython data handling
Python data handling
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptx
 
Unitii string
Unitii stringUnitii string
Unitii string
 
c programming
c programmingc programming
c programming
 
Strings(2007)
Strings(2007)Strings(2007)
Strings(2007)
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Week6_P_String.pptx
Week6_P_String.pptxWeek6_P_String.pptx
Week6_P_String.pptx
 

string

  • 1. Name:- Dhanraj Vaghela Branch:- Mechanical (2nd sem) Enroll. No.:- 140990119060 From the desk of Dhanraj from SRICT
  • 2. Strings A special kind of array is an array of characters ending in the null character 0 called string arrays A string is declared as an array of characters char s[10] char p[30] When declaring a string don’t forget to leave a space for the null character which is also known as the string terminator character From the desk of Dhanraj from SRICT
  • 3. String storage •These functions with formate specifiers %c &%s can be used for input & output of charactors and strings. Examples :- Scanf(“%c”,&colour); // reading character Scanf(“%s”,colour); // reading string Scanf(“%c”,colour); // writing character Scanf(“%c”,colour); // writing string From the desk of Dhanraj from SRICT
  • 4. Strlen(s1) :- returns the length of the string s1 excluding the null character. Strlwr(s1):- converts the string s1 to lower case. Strcat(s1,s2):- appends a copy of string s2 to the end of s1 and terminates s1 with a null and returns s1. Strcpy(s1,s2):- copies the srring s2 into string s1 ,modifying the string s1. Strcmpi(s1,s2):- compares s1 &s2 ignoring the cas and returns similler result as strcmp. Strupr(s1):-converts the string s1 to uppercase. Strchr(s1,c):-returns a pointer to the first occurrence of the character c in string s1. Strstr(s1,s2):- returns a pointer to the first occurrence of the string s1 in string s2. Strrev(s1):- returns the reverse string of string s1.From the desk of Dhanraj from SRICT
  • 5. Four main operations on strings strcpy - copy one string into another strcat - append one string onto the right side of the other strcmp – compare alphabetic order of two strings strlen – return the length of a string From the desk of Dhanraj from SRICT
  • 6. strcpy strcpy(destinationstring, sourcestring) Copies sourcestring into destinationstring For example strcpy(str, “hello world”); assigns “hello world” to the string str From the desk of Dhanraj from SRICT
  • 7. strcat strcat(destinationstring, sourcestring) appends sourcestring to right hand side of destinationstring For example if str had value “a big ” strcat(str, “hello world”); appends “hello world” to the string “a big ” to get “ a big hello world” From the desk of Dhanraj from SRICT
  • 8. strcmp strcmp(stringa, stringb) Compares stringa and stringb alphabetically Returns a negative value if stringa precedes stringb alphabetically Returns a positive value if stringb precedes stringa alphabetically Returns 0 if they are equal Note lowercase characters are greater than Uppercase From the desk of Dhanraj from SRICT
  • 9. strlen strlen(str) returns length of string excluding null character strlen(“tttt”) = 4 not 5 since 0 not counted From the desk of Dhanraj from SRICT
  • 10. Input output functions of characters and strings getchar() reads a character from the screen in a non- interactive environment getche() like getchar() except interactive putchar(int ch) outputs a character to screen gets(str) gets a string from the keyboard puts(str) outputs string to screen From the desk of Dhanraj from SRICT
  • 11. From the desk of Dhanraj from SRICT