SlideShare a Scribd company logo
3
Most read
4
Most read
11
Most read
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)

PPTX
C Token’s
Tarun Sharma
 
PPTX
Strings in C
Kamal Acharya
 
PDF
Strings in Python
nitamhaske
 
PPTX
Python strings presentation
VedaGayathri1
 
PPTX
Python variables and data types.pptx
AkshayAggarwal79
 
PPTX
Unit 2. Elements of C
Ashim Lamichhane
 
PPTX
Strings in C language
P M Patil
 
PPTX
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
SKUP1
 
PPT
Strings Functions in C Programming
DevoAjit Gupta
 
PPTX
Constants, Variables, and Data Types
Rokonuzzaman Rony
 
PPTX
Presentation on c structures
topu93
 
PPTX
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
PPTX
Java input
Jin Castor
 
PPTX
The string class
Syed Zaid Irshad
 
PPT
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
PPTX
String in c programming
Devan Thakur
 
PPTX
Variables in C++, data types in c++
Neeru Mittal
 
PPTX
Basic Data Types in C++
Hridoy Bepari
 
C Token’s
Tarun Sharma
 
Strings in C
Kamal Acharya
 
Strings in Python
nitamhaske
 
Python strings presentation
VedaGayathri1
 
Python variables and data types.pptx
AkshayAggarwal79
 
Unit 2. Elements of C
Ashim Lamichhane
 
Strings in C language
P M Patil
 
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
SKUP1
 
Strings Functions in C Programming
DevoAjit Gupta
 
Constants, Variables, and Data Types
Rokonuzzaman Rony
 
Presentation on c structures
topu93
 
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
Java input
Jin Castor
 
The string class
Syed Zaid Irshad
 
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
String in c programming
Devan Thakur
 
Variables in C++, data types in c++
Neeru Mittal
 
Basic Data Types in C++
Hridoy Bepari
 

Similar to Operation on string presentation (20)

PPT
Strings(2007)
svit vasad
 
PDF
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
PDF
Strings in c mrs.sowmya jyothi
Sowmya Jyothi
 
PPT
String c
thirumalaikumar3
 
PPTX
Strings CPU GTU
Maharshi Dave
 
PPTX
fundamentals of c programming_String.pptx
JStalinAsstProfessor
 
PDF
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
PPT
Strings in c
vampugani
 
PDF
0-Slot21-22-Strings.pdf
ssusere19c741
 
PPTX
24_2-String and String Library.pptx
GandavadiVenkatesh1
 
PPTX
Programming in C - Fundamental Study of Strings
Dr. Chandrakant Divate
 
PPTX
Presentation more c_programmingcharacter_and_string_handling_
KarthicaMarasamy
 
PDF
strings-150319180934-conversion-gate01.pdf
HEMAHEMS5
 
PDF
Principals of Programming in CModule -5.pdfModule-4.pdf
anilcsbs
 
PPT
CP-STRING (1).ppt
mounikanarra3
 
PPT
CP-STRING.ppt
TAPANDDRAW
 
PPT
CP-STRING.ppt
arunatluri
 
PPT
CPSTRINGSARGAVISTRINGS.PPT
Sasideepa
 
PPT
BHARGAVISTRINGS.PPT
Sasideepa
 
Strings(2007)
svit vasad
 
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
Strings in c mrs.sowmya jyothi
Sowmya Jyothi
 
Strings CPU GTU
Maharshi Dave
 
fundamentals of c programming_String.pptx
JStalinAsstProfessor
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Strings in c
vampugani
 
0-Slot21-22-Strings.pdf
ssusere19c741
 
24_2-String and String Library.pptx
GandavadiVenkatesh1
 
Programming in C - Fundamental Study of Strings
Dr. Chandrakant Divate
 
Presentation more c_programmingcharacter_and_string_handling_
KarthicaMarasamy
 
strings-150319180934-conversion-gate01.pdf
HEMAHEMS5
 
Principals of Programming in CModule -5.pdfModule-4.pdf
anilcsbs
 
CP-STRING (1).ppt
mounikanarra3
 
CP-STRING.ppt
TAPANDDRAW
 
CP-STRING.ppt
arunatluri
 
CPSTRINGSARGAVISTRINGS.PPT
Sasideepa
 
BHARGAVISTRINGS.PPT
Sasideepa
 
Ad

Recently uploaded (20)

PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
smart lot access control system with eye
rasabzahra
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
smart lot access control system with eye
rasabzahra
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Ad

Operation on string presentation

  • 1. Submited by: Md: Aliul Kadir akib Daffodil international university mail:[email protected] 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.