SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
C++ PROGRAM
STRING
BY:B.DHEENADAYALAN
STRING
String is a sequence of character or collection of character or array of
Character.
CHARACTER:
★ It represent a single letter within the single codes.
★ Example: ‘h’,’e’,’l’,’l’,’o’.
STRING:
★ It represent a collection of character within double codes.
★ Example:”hello”.
TYPES OF DECLARATION:
C++ provides following two types of string representations:
● The C-style character string.
● The string class type introduced with Standard c++
C STYLE DECLARATION SYNTAX:
● char string_name [size of the string];
STANDARD C++ DECLARATION SYNTAX:
● string name[size of the string];
INITIALIZATION:
● Using single character constant eg: string s1={‘h’,’e’,’l’,’l’,’o’,’0’};
● Using string constant eg: string s2={“hello”};
● String s3=s2; copy initialization
● String s4(s1); direct initialization
● String s5(6,’d’);  concatenates
● String s6;
cout<<”enter the string”;
cin>>s6;
cout<<”you entered”<<s6;  string was choosed by the user.
● length = s6.size();
cout<<length;  to identify the size.
Memory Presentation :
●
SOME OF THE FUNCTION AND PURPOSE :
1. strcpy(s1, s2); Copies string s2 into string s1.
2. strcat(s1, s2); Concatenates string s2 onto the end of string s1.
3. strlen(s1); Returns the length of string s1.
4. strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than
if s1<s2; greater than 0 if s1>s2.
5.strchr(s1, ch); Returns a pointer to the first occurrence of
character ch in string s1.
6.strstr(s1, s2); Returns a pointer to the first occurrence of string
s2 in string s1.
THANK YOU!

More Related Content

PPTX
Call by value or call by reference in C++
PPTX
Constructors and destructors
PDF
Files and streams
PPTX
Polymorphism in C++
PPTX
Strings in c++
PPTX
Introduction Of C++
PPTX
Templates in C++
PDF
Constructor and Destructor
Call by value or call by reference in C++
Constructors and destructors
Files and streams
Polymorphism in C++
Strings in c++
Introduction Of C++
Templates in C++
Constructor and Destructor

What's hot (20)

PPTX
Identifiers
PPTX
Array in C
PPS
String and string buffer
PPTX
Strings in Java
PPTX
PPTX
INLINE FUNCTION IN C++
PPTX
Templates in c++
PPTX
The string class
PPTX
PDF
Managing I/O in c++
PPTX
String C Programming
PDF
PDF
Methods in Java
PPTX
PPTX
Tokens in C++
PPTX
Polymorphism In c++
PPTX
Operator overloading
PDF
Operator overloading
PPTX
Unit 2. Elements of C
PPTX
C programming - String
Identifiers
Array in C
String and string buffer
Strings in Java
INLINE FUNCTION IN C++
Templates in c++
The string class
Managing I/O in c++
String C Programming
Methods in Java
Tokens in C++
Polymorphism In c++
Operator overloading
Operator overloading
Unit 2. Elements of C
C programming - String
Ad

Similar to C++ string (20)

PPTX
lecture-5 string.pptx
PPTX
3 (3)Arrays and Strings for 11,12,college.pptx
PPTX
String in programming language in c or c++
PPTX
String Handling in c++
PPTX
ppt8-string-1.pptx
PDF
String class and function for b.tech iii year students
PDF
C string _updated_Somesh_SSTC_ Bhilai_CG
PDF
Chapter 3 - Characters and Strings - Student.pdf
PPT
Computer Programming- Lecture 6
PPT
lecture5.ppt
PPT
C++ Strings.ppt
PPTX
String handling
PPT
Strings
PPT
Strings
PPT
Strings
PPT
lecture 5 string in c++ explaination and example.ppt
PDF
Strings1
PDF
Strinng Classes in c++
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Strings in c plus plus
lecture-5 string.pptx
3 (3)Arrays and Strings for 11,12,college.pptx
String in programming language in c or c++
String Handling in c++
ppt8-string-1.pptx
String class and function for b.tech iii year students
C string _updated_Somesh_SSTC_ Bhilai_CG
Chapter 3 - Characters and Strings - Student.pdf
Computer Programming- Lecture 6
lecture5.ppt
C++ Strings.ppt
String handling
Strings
Strings
Strings
lecture 5 string in c++ explaination and example.ppt
Strings1
Strinng Classes in c++
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Strings in c plus plus
Ad

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
web development for engineering and engineering
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Well-logging-methods_new................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Geodesy 1.pptx...............................................
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
DOCX
573137875-Attendance-Management-System-original
PPTX
Welding lecture in detail for understanding
PPTX
Sustainable Sites - Green Building Construction
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Digital Logic Computer Design lecture notes
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
CH1 Production IntroductoryConcepts.pptx
web development for engineering and engineering
Embodied AI: Ushering in the Next Era of Intelligent Systems
Well-logging-methods_new................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Foundation to blockchain - A guide to Blockchain Tech
Geodesy 1.pptx...............................................
Automation-in-Manufacturing-Chapter-Introduction.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
573137875-Attendance-Management-System-original
Welding lecture in detail for understanding
Sustainable Sites - Green Building Construction
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf

C++ string

  • 2. STRING String is a sequence of character or collection of character or array of Character. CHARACTER: ★ It represent a single letter within the single codes. ★ Example: ‘h’,’e’,’l’,’l’,’o’. STRING: ★ It represent a collection of character within double codes. ★ Example:”hello”.
  • 3. TYPES OF DECLARATION: C++ provides following two types of string representations: ● The C-style character string. ● The string class type introduced with Standard c++ C STYLE DECLARATION SYNTAX: ● char string_name [size of the string]; STANDARD C++ DECLARATION SYNTAX: ● string name[size of the string];
  • 4. INITIALIZATION: ● Using single character constant eg: string s1={‘h’,’e’,’l’,’l’,’o’,’0’}; ● Using string constant eg: string s2={“hello”}; ● String s3=s2; copy initialization ● String s4(s1); direct initialization ● String s5(6,’d’); concatenates ● String s6; cout<<”enter the string”; cin>>s6; cout<<”you entered”<<s6; string was choosed by the user.
  • 5. ● length = s6.size(); cout<<length; to identify the size. Memory Presentation : ●
  • 6. SOME OF THE FUNCTION AND PURPOSE : 1. strcpy(s1, s2); Copies string s2 into string s1. 2. strcat(s1, s2); Concatenates string s2 onto the end of string s1. 3. strlen(s1); Returns the length of string s1. 4. strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than if s1<s2; greater than 0 if s1>s2. 5.strchr(s1, ch); Returns a pointer to the first occurrence of character ch in string s1. 6.strstr(s1, s2); Returns a pointer to the first occurrence of string s2 in string s1.