SlideShare a Scribd company logo
1 of 13
Submited by:
Md: Aliul Kadir akib
Daffodil international university
mail:aliulkadir@gmail.com
Welcome to CSE PRESENTATION
Topics:
Operation On String
1.Strings
2.Memory Storage for a String
3.Input/Output of a String
Right and Left Justification of Strings
An Example of Manipulating String with scanf and
printf
String Library Functions
Some String Functions from String.h
Functions strcat and strlen
Character Analysis and Conversion
CONTENT
Strings
• C implements the stringstring data structure using
arrays of type char.
• You have already used the string extensively.
– printf(“This program is terminated!n”);
• Since stringstring is an array, the declaration of a
string is the same as declaring a char array.
– char string_var[30];
– char string_var[20] = “Initial value”;
Memory Storage for a String
• The string is always ended with a nullnull
charactercharacter ‘0’‘0’.
• The characters after the null character are
ignored.
• e.g., char str[20] = “Initial value”;
n i t i a l v a l u e ? ? …I 00
[0] [13]
Memory Storage for a String
• An array of strings is a two-dimensional array of
characters in which each row is one string.
– char names[People][Length];
– char month[5][10] = {“January”,
“February”, “March”, “April”,
“May”};
Input/Output of a String
• The placeholder %s%s is used to represent string
arguments in printf and scanf.
– printf(“Topic: %sn”, string_var);
• The string can be right-justified by placing a
positive number in the placeholder.
– printf(“%8s%8s”, str);
• The string can be left-justified by placing a
negative number in the placeholder.
– Printf(“%-8s%-8s”, str);
Right and Left Justification of
Strings
The “%8s%8s” placeholder displays a string which is right-
justified and in 8-columns width.
If the actual string is longer than the width, the displayed field
is expanded with no padding.
Copyright ©2004 Pearson Addison-Wesley. All rights reserved.
An Example of Manipulating String
with scanf and printf
The dept is the initial memory
address of the string argument. Thus
we don’t apply the & operator on it.
String Library Functions
• The string can not be copied by the assignment
operator ‘=’.
– e..g, “str = “Test String”” is not valid.
• C provides string manipulating functions in the
“string.h” library.
– The complete list of these functions can be found in
Appendix B of the textbook.
Some String Functions from String.h
Function Purpose Example
strcpy Makes a copy of a
string
strcpy(s1, “Hi”);
strcat Appends a string to the
end of another string
strcat(s1, “more”);
strcmp Compare two strings
alphabetically
strcmp(s1, “Hu”);
strlen Returns the number of
characters in a string
strlen(“Hi”)
returns 2.
strtok Breaks a string into
tokens by delimiters.
strtok(“Hi, Chao”,
“ ,”);
Functions strcat and strlen
• Functions strcat and strncat concatenate
the fist string argument with the second string
argument.
– strcat(dest, “more..”);
– strncat(dest, “more..”, 3);
• Function strlen is often used to check the
length of a string (i.e., the number of characters
before the fist null character).
– e.g., dest[6] = “Hello”;
strncat(dest, “more”, 5-strlen(dest));
dest[5] = ‘0’;
Character Analysis and Conversion
• The <ctype.h><ctype.h> library defines facilities for character
analysis and conversion.
Functions Description
isalpha Check if the argument is a letter
isdigit Check if the argument is one of the ten digits
isspace Check if argument is a space, newline or tab.
tolower Converts the lowercase letters in the
argument to upper case letters.
Operation on string presentation

More Related Content

What's hot (20)

Structure in c
Structure in cStructure in c
Structure in c
 
String in c programming
String in c programmingString in c programming
String in c programming
 
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++
 
C programming - String
C programming - StringC programming - String
C programming - String
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
C++ string
C++ stringC++ string
C++ string
 
Function
FunctionFunction
Function
 
C functions
C functionsC functions
C functions
 
Strings in c
Strings in cStrings in c
Strings in c
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
File in C language
File in C languageFile in C language
File in C language
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
String c
String cString c
String c
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Strings
StringsStrings
Strings
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 

Similar to Operation on string presentation

Similar to Operation on string presentation (20)

introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
string in C
string in Cstring in C
string in C
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptx
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Team 1
Team 1Team 1
Team 1
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 
Strings(2007)
Strings(2007)Strings(2007)
Strings(2007)
 
5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing
 
Strings CPU GTU
Strings CPU GTUStrings CPU GTU
Strings CPU GTU
 
characters_strings.pdf
characters_strings.pdfcharacters_strings.pdf
characters_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
 
Strings
StringsStrings
Strings
 
Week6_P_String.pptx
Week6_P_String.pptxWeek6_P_String.pptx
Week6_P_String.pptx
 
[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++
 
CPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPTCPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPT
 
BHARGAVISTRINGS.PPT
BHARGAVISTRINGS.PPTBHARGAVISTRINGS.PPT
BHARGAVISTRINGS.PPT
 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
 
CP-STRING (1).ppt
CP-STRING (1).pptCP-STRING (1).ppt
CP-STRING (1).ppt
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 

Operation on string presentation

  • 1. Submited by: Md: Aliul Kadir akib Daffodil international university mail:aliulkadir@gmail.com Welcome to CSE PRESENTATION Topics: Operation On String
  • 2. 1.Strings 2.Memory Storage for a String 3.Input/Output of a String Right and Left Justification of Strings An Example of Manipulating String with scanf and printf String Library Functions Some String Functions from String.h Functions strcat and strlen Character Analysis and Conversion CONTENT
  • 3. Strings • C implements the stringstring data structure using arrays of type char. • You have already used the string extensively. – printf(“This program is terminated!n”); • Since stringstring is an array, the declaration of a string is the same as declaring a char array. – char string_var[30]; – char string_var[20] = “Initial value”;
  • 4. Memory Storage for a String • The string is always ended with a nullnull charactercharacter ‘0’‘0’. • The characters after the null character are ignored. • e.g., char str[20] = “Initial value”; n i t i a l v a l u e ? ? …I 00 [0] [13]
  • 5. Memory Storage for a String • An array of strings is a two-dimensional array of characters in which each row is one string. – char names[People][Length]; – char month[5][10] = {“January”, “February”, “March”, “April”, “May”};
  • 6. Input/Output of a String • The placeholder %s%s is used to represent string arguments in printf and scanf. – printf(“Topic: %sn”, string_var); • The string can be right-justified by placing a positive number in the placeholder. – printf(“%8s%8s”, str); • The string can be left-justified by placing a negative number in the placeholder. – Printf(“%-8s%-8s”, str);
  • 7. Right and Left Justification of Strings The “%8s%8s” placeholder displays a string which is right- justified and in 8-columns width. If the actual string is longer than the width, the displayed field is expanded with no padding.
  • 8. Copyright ©2004 Pearson Addison-Wesley. All rights reserved. An Example of Manipulating String with scanf and printf The dept is the initial memory address of the string argument. Thus we don’t apply the & operator on it.
  • 9. String Library Functions • The string can not be copied by the assignment operator ‘=’. – e..g, “str = “Test String”” is not valid. • C provides string manipulating functions in the “string.h” library. – The complete list of these functions can be found in Appendix B of the textbook.
  • 10. Some String Functions from String.h Function Purpose Example strcpy Makes a copy of a string strcpy(s1, “Hi”); strcat Appends a string to the end of another string strcat(s1, “more”); strcmp Compare two strings alphabetically strcmp(s1, “Hu”); strlen Returns the number of characters in a string strlen(“Hi”) returns 2. strtok Breaks a string into tokens by delimiters. strtok(“Hi, Chao”, “ ,”);
  • 11. Functions strcat and strlen • Functions strcat and strncat concatenate the fist string argument with the second string argument. – strcat(dest, “more..”); – strncat(dest, “more..”, 3); • Function strlen is often used to check the length of a string (i.e., the number of characters before the fist null character). – e.g., dest[6] = “Hello”; strncat(dest, “more”, 5-strlen(dest)); dest[5] = ‘0’;
  • 12. Character Analysis and Conversion • The <ctype.h><ctype.h> library defines facilities for character analysis and conversion. Functions Description isalpha Check if the argument is a letter isdigit Check if the argument is one of the ten digits isspace Check if argument is a space, newline or tab. tolower Converts the lowercase letters in the argument to upper case letters.